home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / tex / xtexcad-.000 / xtexcad- / orig_src / pickedit.c < prev    next >
C/C++ Source or Header  |  1993-03-04  |  85KB  |  3,934 lines

  1. /* xtexcad  V1.1 - graphic editor for LaTeX */
  2. /* 1991 by K.Zitzmann */
  3. /* pickedit.c */
  4.  
  5. #include "x_stuff.h"
  6. #include "oberfl.h"
  7. #include "ereignis.h"
  8. #include "graphics.h"
  9. #include "pickedit.h"
  10. #include <math.h>
  11.  
  12.  
  13.  
  14. /* this data-structure contains the best matching objects which are */
  15. /* found during a pick-action... */
  16.  
  17. #define sumobj 5
  18.  
  19. int             maxobj = 5;
  20.  
  21. char            kind[sumobj];    /* the object type: 'L'=line, 'V'=vector,
  22.                  * 'N'=framedBox etc */
  23. int             distance[sumobj];    /* the distance to the selected point
  24.                      * on the screen */
  25. void           *obj[sumobj];    /* pointer to the current element in kind[] */
  26. int             tip;
  27.  
  28. int             x_pick, y_pick, currIndex;
  29. /* currIndex is THE index which points ALWAYS to the current object */
  30.  
  31. int             points = 10;    /* radius for edit circle */
  32. /* ----------------------------------- */
  33. /*
  34.  * interface to application is : set_pick_stack(x,y) and nextObject()  and
  35.  * currIndex
  36.  */
  37.  
  38.  
  39. void
  40. init_pick()
  41. {
  42.     int             i;
  43.     for (i = 0; i <= maxobj; i++)
  44.     {
  45.         kind[i] = '-';
  46.         distance[i] = 9999;
  47.         obj[i] = NULL;
  48.     }
  49.  
  50.     tip = 0;
  51.     currIndex = 0;
  52. }
  53.  
  54.  
  55. int
  56. nextObject()
  57. {
  58.     /* returns -1 if there is no object & otherwise the index */
  59.     /* of the object in the global data-stucture */
  60.  
  61.     if (kind[tip] == '-')
  62.         return -1;    /* no object */
  63.  
  64.     if (tip <= maxobj)
  65.         tip++;
  66.     else
  67.         return -1;
  68.  
  69.     currIndex = tip - 1;
  70.  
  71.     return currIndex;
  72. }
  73.  
  74.  
  75.  
  76. void
  77. set_pick_stack(int x, int y)
  78. {
  79.     /* fills the stack with matching objects */
  80.     int             d, res;
  81.     float           h, v;
  82.     init_pick();
  83.  
  84.     if (zoomed == True)
  85.     {
  86.         h = (float) x;
  87.         v = (float) y;
  88.         zoomed2real(&h, &v);
  89.         x = h;
  90.         y = v;
  91.     }
  92.     /* bezier */
  93.     if (bezier_start != NULL)
  94.     {    /* there is min. 1 entry */
  95.         bezier_marker = bezier_start;
  96.         res = analyse_bezier(bezier_marker, &d, x, y);
  97.         if (res == 1)
  98.             insert_object(bezier_marker, d, ii);
  99.  
  100.         if (bezier_marker != bezier_curr)
  101.         {
  102.             do
  103.             {
  104.                 bezier_marker = bezier_marker->next;
  105.                 res = analyse_bezier(bezier_marker, &d, x, y);
  106.                 if (res == 1)
  107.                     insert_object(bezier_marker, d, ii);
  108.             } while (bezier_marker != bezier_curr);
  109.         }
  110.     }
  111.     /* line */
  112.     if (strich_start != NULL)
  113.     {    /* there is min. 1 entry */
  114.         strich_marker = strich_start;
  115.         res = analyse_pin(strich_marker, &d, x, y);
  116.         if (res == 1)
  117.             insert_object(strich_marker, d, ll);
  118.  
  119.         if (strich_marker != strich_curr)
  120.         {
  121.             do
  122.             {
  123.                 strich_marker = strich_marker->next;
  124.                 res = analyse_pin(strich_marker, &d, x, y);
  125.                 if (res == 1)
  126.                     insert_object(strich_marker, d, ll);
  127.             } while (strich_marker != strich_curr);
  128.         }
  129.     }
  130.     /* vector */
  131.     if (pfeil_start != NULL)
  132.     {    /* there is min. 1 entry */
  133.         pfeil_marker = pfeil_start;
  134.         res = analyse_pin(pfeil_marker, &d, x, y);
  135.         if (res == 1)
  136.             insert_object(pfeil_marker, d, vv);
  137.  
  138.         if (pfeil_marker != pfeil_curr)
  139.         {
  140.             do
  141.             {
  142.                 pfeil_marker = pfeil_marker->next;
  143.                 res = analyse_pin(pfeil_marker, &d, x, y);
  144.                 if (res == 1)
  145.                     insert_object(pfeil_marker, d, vv);
  146.             } while (pfeil_marker != pfeil_curr);
  147.         }
  148.     }
  149.     /* framedBox */
  150.     if (framedBox_start != NULL)
  151.     {    /* there is min. 1 entry */
  152.         framedBox_marker = framedBox_start;
  153.         res = analyse_nbox(framedBox_marker, &d, x, y);
  154.         if (res == 1)
  155.             insert_object(framedBox_marker, d, nn);
  156.  
  157.         if (framedBox_marker != framedBox_curr)
  158.         {
  159.             do
  160.             {
  161.                 framedBox_marker = framedBox_marker->next;
  162.                 res = analyse_nbox(framedBox_marker, &d, x, y);
  163.                 if (res == 1)
  164.                     insert_object(framedBox_marker, d, nn);
  165.             } while (framedBox_marker != framedBox_curr);
  166.         }
  167.     }
  168.     /* dashedBox */
  169.     if (dashedBox_start != NULL)
  170.     {    /* there is min. 1 entry */
  171.         dashedBox_marker = dashedBox_start;
  172.         res = analyse_dbox(dashedBox_marker, &d, x, y);
  173.         if (res == 1)
  174.             insert_object(dashedBox_marker, d, dd);
  175.  
  176.         if (dashedBox_marker != dashedBox_curr)
  177.         {
  178.             do
  179.             {
  180.                 dashedBox_marker = dashedBox_marker->next;
  181.                 res = analyse_dbox(dashedBox_marker, &d, x, y);
  182.                 if (res == 1)
  183.                     insert_object(dashedBox_marker, d, dd);
  184.             } while (dashedBox_marker != dashedBox_curr);
  185.         }
  186.     }
  187.     /* filledBox */
  188.     if (filledBox_start != NULL)
  189.     {    /* there is min. 1 entry */
  190.         filledBox_marker = filledBox_start;
  191.         res = analyse_fbox(filledBox_marker, &d, x, y);
  192.         if (res == 1)
  193.             insert_object(filledBox_marker, d, ff);
  194.  
  195.  
  196.  
  197.         if (filledBox_marker != filledBox_curr)
  198.         {
  199.             do
  200.             {
  201.                 filledBox_marker = filledBox_marker->next;
  202.                 res = analyse_fbox(filledBox_marker, &d, x, y);
  203.                 if (res == 1)
  204.                     insert_object(filledBox_marker, d, ff);
  205.             } while (filledBox_marker != filledBox_curr);
  206.         }
  207.     }
  208.     /* normal circle */
  209.     if (kreis_start != NULL)
  210.     {    /* there is min. 1 entry */
  211.         kreis_marker = kreis_start;
  212.         res = analyse_ncircle(kreis_marker, &d, x, y);
  213.         if (res == 1)
  214.             insert_object(kreis_marker, d, cc);
  215.  
  216.         if (kreis_marker != kreis_curr)
  217.         {
  218.             do
  219.             {
  220.                 kreis_marker = kreis_marker->next;
  221.                 res = analyse_ncircle(kreis_marker, &d, x, y);
  222.                 if (res == 1)
  223.                     insert_object(kreis_marker, d, cc);
  224.             } while (kreis_marker != kreis_curr);
  225.         }
  226.     }
  227.     /* filled circle */
  228.     if (disc_start != NULL)
  229.     {    /* there is min. 1 entry */
  230.         disc_marker = disc_start;
  231.         res = analyse_fcircle(disc_marker, &d, x, y);
  232.         if (res == 1)
  233.             insert_object(disc_marker, d, bb);
  234.  
  235.         if (disc_marker != disc_curr)
  236.         {
  237.             do
  238.             {
  239.                 disc_marker = disc_marker->next;
  240.                 res = analyse_fcircle(disc_marker, &d, x, y);
  241.                 if (res == 1)
  242.                     insert_object(disc_marker, d, bb);
  243.             } while (disc_marker != disc_curr);
  244.         }
  245.     }
  246.     /* oval */
  247.     if (oval_start != NULL)
  248.     {    /* there is min. 1 entry */
  249.         oval_marker = oval_start;
  250.         res = analyse_ocircle(oval_marker, &d, x, y);
  251.         if (res == 1)
  252.             insert_object(oval_marker, d, oo);
  253.  
  254.         if (oval_marker != oval_curr)
  255.         {
  256.             do
  257.             {
  258.                 oval_marker = oval_marker->next;
  259.                 res = analyse_ocircle(oval_marker, &d, x, y);
  260.                 if (res == 1)
  261.                     insert_object(oval_marker, d, oo);
  262.             } while (oval_marker != oval_curr);
  263.         }
  264.     }
  265. }
  266.  
  267.  
  268. void
  269. insert_object(void *p, int d, char c)
  270. {
  271.     int             i, k;
  272.     /*
  273.      * operations performed on global data-structure :
  274.      * 
  275.      * 
  276.     /* compute insert-position
  277.      */
  278.     for (i = 0; (distance[i] < d) && (i != maxobj); i++);
  279.  
  280.     if (i == maxobj)
  281.         return;    /* the distance was too far; there are better objects */
  282.  
  283.     /* move elements */
  284.     for (k = (maxobj - 1); k > i; k--)
  285.     {
  286.         kind[k] = kind[k - 1];
  287.         distance[k] = distance[k - 1];
  288.         obj[k] = obj[k - 1];
  289.     }
  290.  
  291.     /* the new entry */
  292.     kind[i] = c;
  293.     distance[i] = d;
  294.     obj[i] = p;
  295.  
  296.     /* fin */
  297.  
  298. }
  299.  
  300.  
  301. /* function int analyse_xxxxxx() : */
  302. /* returns wether the object is a possible pick(1) or not(0) */
  303. /* p points to the object; d returns the distance to the object */
  304. /* xpos,ypos reference the pick position of the pointer */
  305.  
  306.  
  307. int analyse_bezier(struct fig6 *p, int *d, int xpos, int ypos)
  308. {
  309.     int cmpdiff=9999;
  310.     int diff;
  311.     int x,y;
  312.     float u;
  313.     int zone=20;
  314.     
  315.     for (u=0; u<=1; u+=0.1)
  316.     {
  317.         x=(int)(p->ax*(1-u)*(1-u)+p->sx*(1-u)*2*u+p->ex*u*u);
  318.             y=(int)(p->ay*(1-u)*(1-u)+p->sy*(1-u)*2*u+p->ey*u*u);
  319.  
  320.         diff=calc_distance(x,y,xpos,ypos);
  321.         
  322.         cmpdiff=(cmpdiff<diff) ? cmpdiff : diff;
  323.     }
  324.  
  325.     (*d)= cmpdiff;
  326.  
  327.     return (cmpdiff<zone) ? 1 : 0;
  328. }
  329.  
  330.  
  331.  
  332.  
  333. int
  334. analyse_pin(struct fig2 * p, int *d, int xpos, int ypos)
  335. {
  336.     float           d1, d2;
  337.     float           x1, x2, y1, y2;
  338.     float           x, y, h, v;
  339.     float           zone;
  340.     double          alpha;
  341.  
  342.  
  343.     /* 1. test : bounding rectangle */
  344.  
  345.     x = p->x;
  346.     y = p->y;
  347.     v = p->v;
  348.     h = p->h;
  349.  
  350.     zone = 30.0;
  351.  
  352.     norm_rectangle(&x, &y, &h, &v);
  353.     /* now, x,y is the upper left corner of the rectangle */
  354.  
  355.  
  356.  
  357.     x = x - zone;
  358.     h = h + zone;
  359.     y = y - zone;
  360.     v = v + zone;
  361.  
  362.  
  363.     if ((xpos < (int) x) || (xpos > (int) h) || (ypos < (int) y) || (ypos > (int) v))
  364.         return 0;
  365.  
  366.  
  367.  
  368.  
  369.     /* 2. test : distance */
  370.  
  371.     x = (p->x);
  372.     y = (p->y);
  373.  
  374.     /* %%%%%%%%%%%%%%%%%%%%%  see documentation  %%%%%%%%%%%%%%%%%%%%% */
  375.  
  376.     /* Vector 1 */
  377.     x1 = (float) xpos - x;
  378.     x2 = (float) ypos - y;
  379.  
  380.     /* compute length of the above vector */
  381.  
  382.     d1 = (float) sqrt((double) (x1 * x1 + x2 * x2));
  383.     /* --- */
  384.  
  385.     /* Vector 2 */
  386.     y1 = (p->h) - x;
  387.     y2 = (p->v) - y;
  388.  
  389.     d2 = (float) sqrt((double) (y1 * y1 + y2 * y2));
  390.     /* --- */
  391.  
  392.  
  393.     alpha = (double) ((x1 * y1 + x2 * y2) / (d1 * d2));
  394.  
  395.     /* acos(x),-1<=x<=1 */
  396.     if (alpha < -1.0)
  397.         alpha = -1.0;
  398.     if (alpha > 1.0)
  399.         alpha = 1.0;
  400.  
  401.  
  402.     alpha = acos(alpha);
  403.  
  404.  
  405.     (*d) = (int) (d1 * (float) sin(alpha));
  406.  
  407.  
  408.     if ((*d) <= (int) zone)
  409.         return 1;
  410.     else
  411.         return 0;
  412.  
  413. }
  414.  
  415.  
  416.  
  417. int
  418. analyse_nbox(struct fig3 * p, int *d, int xpos, int ypos)
  419. {
  420.     /* normal box */
  421.     float           zone;
  422.     int             x, y, h, v;
  423.     int             dt, db, dr, dl;
  424.  
  425.  
  426.  
  427.     zone = 20.0;
  428.  
  429.     x = (int) ((p->x) - zone);
  430.     y = (int) ((p->y) - zone);
  431.     v = (int) ((p->v) + zone);
  432.     h = (int) ((p->h) + zone);
  433.  
  434.     /* 1. test : bounding rectangle */
  435.  
  436.     if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  437.         return 0;
  438.  
  439.  
  440.     /* 2. test : distance to a boundery */
  441.  
  442.     dl = abs(xpos - (int) (p->x));
  443.     dr = abs(xpos - (int) (p->h));
  444.     dt = abs(ypos - (int) (p->y));
  445.     db = abs(ypos - (int) (p->v));
  446.  
  447.     /* compute the minimum of dr,dl,dt,db and store it in d */
  448.  
  449.     if (dr < dl)
  450.         dl = dr;    /* minimum in dl */
  451.     if (db < dt)
  452.         dt = db;    /* minimum in dt */
  453.  
  454.     if (dt < dl)
  455.         (*d) = dt;
  456.     else
  457.         (*d) = dl;
  458.  
  459.  
  460.     if ((*d) <= (int) zone)
  461.         return 1;
  462.     else
  463.         return 0;
  464.  
  465. }
  466.  
  467.  
  468.  
  469. int
  470. analyse_dbox(struct fig4 * p, int *d, int xpos, int ypos)
  471. {
  472.     /* dashed box */
  473.     float           zone;
  474.     int             x, y, h, v;
  475.     int             dt, db, dr, dl;
  476.     zone = 20;
  477.  
  478.     x = (int) ((p->x) - zone);
  479.     y = (int) ((p->y) - zone);
  480.     v = (int) ((p->v) + zone);
  481.     h = (int) ((p->h) + zone);
  482.  
  483.     /* 1. test : bounding rectangle */
  484.  
  485.     if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  486.         return 0;
  487.  
  488.  
  489.     /* 2. test : distance to a boundery */
  490.  
  491.     dl = abs(xpos - (int) (p->x));
  492.     dr = abs(xpos - (int) (p->h));
  493.     dt = abs(ypos - (int) (p->y));
  494.     db = abs(ypos - (int) (p->v));
  495.  
  496.     /* compute the minimum of dr,dl,dt,db and store it in d */
  497.  
  498.     if (dr < dl)
  499.         dl = dr;    /* minimum in dl */
  500.     if (db < dt)
  501.         dt = db;    /* minimum in dt */
  502.  
  503.     if (dt < dl)
  504.         (*d) = dt;
  505.     else
  506.         (*d) = dl;
  507.  
  508.  
  509.     if ((*d) <= (int) zone)
  510.         return 1;
  511.     else
  512.         return 0;
  513.  
  514. }
  515.  
  516.  
  517.  
  518. int
  519. analyse_fbox(struct fig2 * p, int *d, int xpos, int ypos)
  520. {
  521.     /* filled box */
  522.     int             x, y, h, v;
  523.     x = (int) (p->x);
  524.     y = (int) (p->y);
  525.     v = (int) (p->v);
  526.     h = (int) (p->h);
  527.  
  528.     /* test : bounding rectangle */
  529.  
  530.     if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  531.         return 0;
  532.  
  533.     (*d) = 0;    /* optimal pick */
  534.  
  535.     return 1;
  536.  
  537. }
  538.  
  539.  
  540. int
  541. analyse_ncircle(struct fig2 * p, int *d, int xpos, int ypos)
  542. {
  543.     /* normal circle */
  544.     float           zone;
  545.     int             x, y, h, v;
  546.  
  547.  
  548.     zone = 20.0;
  549.  
  550.     /* x,y is middlepoint/referencepoint */
  551.     x = (int) ((p->x) - zone) - (p->radius);
  552.     y = (int) ((p->y) - zone) - (p->radius);
  553.     v = (int) ((p->y) + zone) + (p->radius);
  554.     h = (int) ((p->x) + zone) + (p->radius);
  555.  
  556.     /* now, x,y,h and v define the boundery-rectangle of the circle */
  557.  
  558.     /* 1. test : bounding rectangle */
  559.  
  560.     if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  561.         return 0;
  562.  
  563.  
  564.     /* 2. test : distance to a boundery (point on the circle-slice) */
  565.     /*
  566.      * compute the difference between radius and the length from
  567.      * (xpos,ypos) to
  568.      */
  569.     /* the midlepoint */
  570.  
  571.     x = xpos - (int) (p->x);
  572.     y = ypos - (int) (p->y);
  573.  
  574.     (*d) = abs((p->radius) -
  575.            (int) sqrt((double) ((float) x * (float) x + (float) y * (float) y)));
  576.  
  577.     if ((*d) <= (int) zone)
  578.         return 1;
  579.     else
  580.         return 0;
  581. }
  582.  
  583.  
  584.  
  585. int
  586. analyse_ocircle(struct fig1 * p, int *d, int xpos, int ypos)
  587. {
  588.     /* oval */
  589.     int             zone;
  590.     int             x, y, h, v;
  591.     int             dt, db, dr, dl;
  592.     zone = 20;
  593.  
  594.     x = (int) (p->x) - zone;
  595.     y = (int) (p->y) - zone;
  596.     v = (int) (p->v) + zone;
  597.     h = (int) (p->h) + zone;
  598.  
  599.     /* 1. test : bounding rectangle */
  600.  
  601.     if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  602.         return 0;
  603.  
  604.  
  605.     /* 2. test : distance to a boundery */
  606.  
  607.     dl = abs(xpos - (int) (p->x));
  608.     dr = abs(xpos - (int) (p->h));
  609.     dt = abs(ypos - (int) (p->y));
  610.     db = abs(ypos - (int) (p->v));
  611.  
  612.  
  613.  
  614.     /* compute the minimum of dr,dl,dt,db and store it in d */
  615.  
  616.     if (dr < dl)
  617.         dl = dr;    /* minimum in dl */
  618.     if (db < dt)
  619.         dt = db;    /* minimum in dt */
  620.  
  621.     if (dt < dl)
  622.         (*d) = dt;
  623.     else
  624.         (*d) = dl;
  625.  
  626.  
  627.     if ((*d) <= zone)
  628.         return 1;
  629.     else
  630.         return 0;
  631.  
  632. }
  633.  
  634.  
  635.  
  636. int
  637. analyse_fcircle(struct fig2 * p, int *d, int xpos, int ypos)
  638. {
  639.     /* filled circle */
  640.     int             x, y, h;
  641.  
  642.  
  643.  
  644.  
  645.     /*
  646.      * 1. test : the position of the selection point must be inside the
  647.      * fille circle
  648.      */
  649.     /*
  650.      * compute the difference between radius and the length from
  651.      * (xpos,ypos) to
  652.      */
  653.     /* the midlepoint */
  654.  
  655.     x = (xpos - (int) (p->x));
  656.     y = (ypos - (int) (p->y));
  657.  
  658.     h = (int) sqrt((double) ((float) x * (float) x + (float) y * (float) y));    /* length of this vector */
  659.  
  660.     if (h < (p->radius))
  661.         (*d) = 0;    /* the selection point is fully inside the
  662.                  * circle */
  663.     else
  664.         return 0;
  665.  
  666.     return 1;
  667. }
  668.  
  669.  
  670.  
  671. void
  672. set_pick_object(void)
  673. {
  674.     /* Override Translation Manager */
  675.     XtTranslations  trans_table;
  676.     char            destination[80] = "<Btn1Up>: manage_pick()";
  677.     static XtActionsRec actions[80] = {{"manage_pick", manage_pick}};
  678.     XtAddActions(actions, XtNumber(actions));
  679.     trans_table = XtParseTranslationTable(destination);
  680.     XtOverrideTranslations(pboard, trans_table);
  681. }
  682.  
  683.  
  684. void
  685. set_copy_object(void)
  686. {
  687.     /* Override Translation Manager */
  688.     XtTranslations  trans_table;
  689.     char            destination[80] = "<Btn1Down>: manage_copy()";
  690.     static XtActionsRec actions[80] = {{"manage_copy", manage_copy}};
  691.     XtAddActions(actions, XtNumber(actions));
  692.     trans_table = XtParseTranslationTable(destination);
  693.     XtOverrideTranslations(pboard, trans_table);
  694. }
  695.  
  696.  
  697.  
  698. void
  699. leave_pick(char *message)
  700. {
  701.     Position        xx, yy, y_rel, x_rel;
  702.     n = 0;
  703.     XtSetArg(args[n], XtNx, &x_rel);
  704.     n++;
  705.     XtSetArg(args[n], XtNy, &y_rel);
  706.     n++;
  707.     XtGetValues(pboard, args, n);
  708.     XtTranslateCoords(canvas, x_rel, y_rel, &xx, &yy);
  709.     n = 0;
  710.     XtSetArg(args[n], XtNx, 175 + xx);
  711.     n++;
  712.     XtSetArg(args[n], XtNy, 295 + yy);
  713.     n++;
  714.  
  715.     XtSetValues(sign_up, args, n);
  716.  
  717.     n = 0;
  718.     XtSetArg(args[n], XtNlabel, message);
  719.     n++;
  720.     XtSetValues(sign_msg, args, n);
  721.     XtPopupSpringLoaded(sign_up);
  722. }
  723.  
  724.  
  725. void
  726. manage_pick(void)
  727. {
  728.  
  729.  
  730.     int             index;
  731.     unsigned int    mask;
  732.  
  733.  
  734.  
  735.  
  736.     PointerPosition(&x_pick, &y_pick, &mask);
  737.  
  738.     XtUninstallTranslations(pboard);
  739.  
  740.     set_pick_stack(x_pick, y_pick);    /* pick_stack is filled with matching
  741.                      * objects */
  742.  
  743.     index = nextObject();
  744.  
  745.     if (index == -1)
  746.     {    /* no objects found */
  747.         left();
  748.         leave_pick("No valid object found !");
  749.         return;
  750.     } else
  751.         pick_manager();
  752. }
  753.  
  754.  
  755.  
  756.  
  757.  
  758. void
  759. pick_manager()
  760. {
  761.     int             btn1 = 256, btn2 = 512, btn3 = 1024;
  762.     int             index;
  763.     int             x, y, h, v;
  764.     unsigned int    mask, mask2;
  765.     Display        *disp = XtDisplay(pboard);
  766.     Window          win = XtWindow(pboard);
  767.     headline(toplevel, "Actions: Button 1 to EDIT ---- Button 2 to MOVE ---- Button 3 for MORE");
  768.  
  769.     while (True)
  770.     {
  771.  
  772.         prepare_top_stack_object();
  773.  
  774.         do
  775.         {    /* watch for any buttonPress */
  776.             PointerPosition(&x, &y, &mask);
  777.             if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  778.             {
  779.                 left();
  780.                 prepare_top_stack_object();
  781.                 return;
  782.             }
  783.             draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  784.  
  785.         } while (!((mask & btn3) || (mask & btn2) || (mask & btn1)));
  786.  
  787.         do
  788.         {
  789.             PointerPosition(&h, &v, &mask2);
  790.         } while ((mask2 & btn3));
  791.  
  792.  
  793.         prepare_top_stack_object();
  794.  
  795.         if (mask & btn1)
  796.             pick_edit();
  797.         else if (mask & btn2)
  798.             index = pick_move(x, y);
  799.         else
  800.         {    /* more */
  801.             index = nextObject();
  802.  
  803.             if (index == -1)
  804.             {    /* no objects found */
  805.                 left();
  806.                 leave_pick("No valid object found !");
  807.                 return;
  808.             }
  809.         }
  810.  
  811.     }    /* while */
  812. }
  813.  
  814.  
  815.  
  816. int
  817. pick_move(int startx, int starty)
  818. {
  819.     /* currIndex points to object-reference in global database */
  820.  
  821.     struct fig1    *one;
  822.     struct fig2    *two;
  823.     struct fig3    *three;
  824.     struct fig4    *four;
  825.     struct fig6    *six;    
  826.     int             x, y, h, v, oldh, oldv;
  827.     unsigned int    mask;
  828.     Display        *disp = XtDisplay(pboard);
  829.     Window          win = XtWindow(pboard);
  830.     int             btn1 = 256, btn2 = 512, btn3 = 1024;
  831.     float           ax, bx, ay, by, sx, sy;
  832.     int             rad;
  833.     float           zoomx, zoomy, zoomh, zoomv, zoomsx, zoomsy;
  834.     Boolean         redraw;
  835.     int             snapx, snapy;
  836.  
  837.  
  838.     by = -999.0;
  839.     oldh = -999;
  840.     oldv = oldh;
  841.  
  842.  
  843.     do
  844.     {
  845.         PointerPosition(&x, &y, &mask);
  846.  
  847.         draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  848.  
  849.         switch (kind[currIndex])
  850.         {
  851.         case 'I':
  852.             six = (struct fig6 *) obj[currIndex];
  853.             h = x - startx;
  854.             v = y - starty;
  855.             if ((oldh != h) || (oldv != v))
  856.             {
  857.                 oldh = h;
  858.                 oldv = v;
  859.                 zoomx = six->ax;
  860.                 zoomy = six->ay;
  861.                 zoomh = six->ex;
  862.                 zoomv = six->ey;
  863.                 zoomsx = six->sx;
  864.                 zoomsy = six->sy;
  865.                 
  866.                 if (zoomed == True) real2zoomed(&zoomsx, &zoomsy);
  867.                 
  868.                 /* delete old line */
  869.                 if (by == -999.0)
  870.                     DrawBezier(zoomx, zoomy, zoomh, zoomv, zoomsx, zoomsy);
  871.                 else
  872.                     DrawBezier(ax, ay, bx, by, sx, sy);
  873.                     
  874.                 if (zoomed == True) 
  875.                 {
  876.                     real2zoomed(&zoomx, &zoomy);
  877.                     real2zoomed(&zoomh, &zoomv);
  878.                 }
  879.                 ax = zoomx + (float) h;
  880.                 ay = zoomy + (float) v;
  881.                 bx = zoomh + (float) h;
  882.                 by = zoomv + (float) v;
  883.                 sx = zoomsx + (float) h;
  884.                 sy = zoomsy + (float) v;
  885.  
  886.                 if ((snap == True) && (raster == True))
  887.                 {
  888.                     snapx = (int) ax;
  889.                     snapy = (int) ay;
  890.                     valid_snap_coords(&snapx, &snapy);
  891.                     bx -= (ax - (float) snapx);
  892.                     by -= (ay - (float) snapy);
  893.                     sx -= (ax - (float) snapx);
  894.                     sy -= (ay - (float) snapy);
  895.                     ax = (float) snapx;
  896.                     ay = (float) snapy;
  897.                 }
  898.                 /* draw new line */
  899.                 
  900.                 if (zoomed==True)
  901.                 {
  902.                     zoomed2real(&ax,&ay);
  903.                     zoomed2real(&bx,&by);
  904.                 }
  905.                 
  906.                 DrawBezier(ax, ay, bx, by, sx, sy);
  907.             }
  908.             break;
  909.  
  910.         case 'L':
  911.             two = (struct fig2 *) obj[currIndex];
  912.             h = x - startx;
  913.             v = y - starty;
  914.             if ((oldh != h) || (oldv != v))
  915.             {
  916.                 oldh = h;
  917.                 oldv = v;
  918.                 zoomx = two->x;
  919.                 zoomy = two->y;
  920.                 zoomh = two->h;
  921.                 zoomv = two->v;
  922.                 if (zoomed == True)
  923.                 {
  924.                     real2zoomed(&zoomx, &zoomy);
  925.                     real2zoomed(&zoomh, &zoomv);
  926.                 }
  927.                 /* delete old line */
  928.                 if (by == -999.0)
  929.                     XDrawLine(disp, win, gc, (int) zoomx, (int) zoomy,
  930.                           (int) zoomh, (int) zoomv);
  931.                 else
  932.                     XDrawLine(disp, win, gc, (int) ax, (int) ay,
  933.                           (int) bx, (int) by);
  934.                 ax = zoomx + (float) h;
  935.                 ay = zoomy + (float) v;
  936.                 bx = zoomh + (float) h;
  937.                 by = zoomv + (float) v;
  938.  
  939.                 if ((snap == True) && (raster == True))
  940.                 {
  941.                     snapx = (int) ax;
  942.                     snapy = (int) ay;
  943.                     valid_snap_coords(&snapx, &snapy);
  944.                     bx -= (ax - (float) snapx);
  945.                     by -= (ay - (float) snapy);
  946.                     ax = (float) snapx;
  947.                     ay = (float) snapy;
  948.                 }
  949.                 /* draw new line */
  950.                 XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  951.             }
  952.             break;
  953.  
  954.         case 'V':
  955.             h = x - startx;
  956.             v = y - starty;
  957.             if ((oldh != h) || (oldv != v))
  958.             {
  959.                 oldh = h;
  960.                 oldv = v;
  961.                 two = (struct fig2 *) obj[currIndex];
  962.                 zoomx = two->x;
  963.                 zoomy = two->y;
  964.                 zoomh = two->h;
  965.                 zoomv = two->v;
  966.                 if (zoomed == True)
  967.                 {
  968.                     real2zoomed(&zoomx, &zoomy);
  969.                     real2zoomed(&zoomh, &zoomv);
  970.                 }
  971.                 if (by == -999.0)
  972.                 {
  973.                     XDrawLine(disp, win, gc, (int) zoomx, (int) zoomy,
  974.                           (int) zoomh, (int) zoomv);
  975.                     draw_vector_marker(zoomx, zoomy, zoomh, zoomv);
  976.                 } else
  977.                 {
  978.                     XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  979.                     draw_vector_marker(ax, ay, bx, by);
  980.                 }
  981.                 ax = zoomx + (float) h;
  982.                 ay = zoomy + (float) v;
  983.                 bx = zoomh + (float) h;
  984.                 by = zoomv + (float) v;
  985.  
  986.                 if ((snap == True) && (raster == True))
  987.                 {
  988.                     snapx = (int) ax;
  989.                     snapy = (int) ay;
  990.                     valid_snap_coords(&snapx, &snapy);
  991.                     bx -= (ax - (float) snapx);
  992.                     by -= (ay - (float) snapy);
  993.                     ax = (float) snapx;
  994.                     ay = (float) snapy;
  995.                 }
  996.                 XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  997.                 draw_vector_marker(ax, ay, bx, by);
  998.             }
  999.             break;
  1000.  
  1001.         case 'N':
  1002.             h = x - startx;
  1003.             v = y - starty;
  1004.             if ((oldh != h) || (oldv != v))
  1005.             {
  1006.                 oldh = h;
  1007.                 oldv = v;
  1008.                 three = (struct fig3 *) obj[currIndex];
  1009.                 zoomx = three->x;
  1010.                 zoomy = three->y;
  1011.                 zoomh = three->h;
  1012.                 zoomv = three->v;
  1013.                 if (zoomed == True)
  1014.                 {
  1015.                     real2zoomed(&zoomx, &zoomy);
  1016.                     real2zoomed(&zoomh, &zoomv);
  1017.                 }
  1018.                 if (by == -999.0)
  1019.                 {
  1020.                     XDrawRectangle(disp, win, gc, (int) zoomx, (int) zoomy,
  1021.                          (unsigned int) (zoomh - zoomx),
  1022.                         (unsigned int) (zoomv - zoomy));
  1023.                     print_box_text(three->textpos, zoomx, zoomy, zoomh, zoomv, three->text);
  1024.                 } else
  1025.                 {
  1026.                     XDrawRectangle(disp, win, gc, ax, ay,
  1027.                            (unsigned int) (bx - ax),
  1028.                           (unsigned int) (by - ay));
  1029.                     XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1030.                     XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1031.                 }
  1032.                 ax = zoomx + (float) h;
  1033.                 ay = zoomy + (float) v;
  1034.                 bx = zoomh + (float) h;
  1035.                 by = zoomv + (float) v;
  1036.  
  1037.                 if ((snap == True) && (raster == True))
  1038.                 {
  1039.                     snapx = (int) ax;
  1040.                     snapy = (int) ay;
  1041.                     valid_snap_coords(&snapx, &snapy);
  1042.                     bx -= (ax - (float) snapx);
  1043.                     by -= (ay - (float) snapy);
  1044.                     ax = (float) snapx;
  1045.                     ay = (float) snapy;
  1046.                 }
  1047.                 XDrawRectangle(disp, win, gc, ax, ay,
  1048.                            (unsigned int) (bx - ax),
  1049.                            (unsigned int) (by - ay));
  1050.                 XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1051.                 XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1052.             }
  1053.             break;
  1054.  
  1055.         case 'D':
  1056.             h = x - startx;
  1057.             v = y - starty;
  1058.             if ((h != oldh) || (v != oldv))
  1059.             {
  1060.                 oldh = h;
  1061.                 oldv = v;
  1062.                 four = (struct fig4 *) obj[currIndex];
  1063.                 zoomx = four->x;
  1064.                 zoomy = four->y;
  1065.                 zoomh = four->h;
  1066.                 zoomv = four->v;
  1067.                 XSetLineAttributes(disp, gc, 0, LineOnOffDash, CapButt, JoinMiter);
  1068.                 if (zoomed == True)
  1069.                 {
  1070.                     real2zoomed(&zoomx, &zoomy);
  1071.                     real2zoomed(&zoomh, &zoomv);
  1072.                 }
  1073.                 if (by == -999.0)
  1074.                 {
  1075.                     XDrawRectangle(disp, win, gc, (int) zoomx, (int) zoomy,
  1076.                          (unsigned int) (zoomh - zoomx),
  1077.                         (unsigned int) (zoomv - zoomy));
  1078.                     print_box_text(four->textpos, zoomx, zoomy, zoomh, zoomv, four->text);
  1079.                 } else
  1080.                 {
  1081.                     XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1082.                            (unsigned int) (bx - ax),
  1083.                           (unsigned int) (by - ay));
  1084.                     XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1085.                     XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1086.                 }
  1087.                 ax = zoomx + (float) h;
  1088.                 ay = zoomy + (float) v;
  1089.                 bx = zoomh + (float) h;
  1090.                 by = zoomv + (float) v;
  1091.  
  1092.                 if ((snap == True) && (raster == True))
  1093.                 {
  1094.                     snapx = (int) ax;
  1095.                     snapy = (int) ay;
  1096.                     valid_snap_coords(&snapx, &snapy);
  1097.                     bx -= (ax - (float) snapx);
  1098.                     by -= (ay - (float) snapy);
  1099.                     ax = (float) snapx;
  1100.                     ay = (float) snapy;
  1101.                 }
  1102.                 XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1103.                            (unsigned int) (bx - ax),
  1104.                            (unsigned int) (by - ay));
  1105.                 XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1106.                 XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1107.                 XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  1108.             }
  1109.             break;
  1110.  
  1111.         case 'F':
  1112.             h = x - startx;
  1113.             v = y - starty;
  1114.             if ((oldh != h) || (oldv != v))
  1115.             {
  1116.                 oldh = h;
  1117.                 oldv = v;
  1118.                 two = (struct fig2 *) obj[currIndex];
  1119.                 zoomx = two->x;
  1120.                 zoomy = two->y;
  1121.                 zoomh = two->h;
  1122.                 zoomv = two->v;
  1123.                 if (zoomed == True)
  1124.                 {
  1125.                     real2zoomed(&zoomx, &zoomy);
  1126.                     real2zoomed(&zoomh, &zoomv);
  1127.                 }
  1128.                 if (by == -999.0)
  1129.                 {
  1130.                     XFillRectangle(disp, win, gc, (int) zoomx, (int) zoomy,
  1131.                          (unsigned int) (zoomh - zoomx),
  1132.                         (unsigned int) (zoomv - zoomy));
  1133.                 } else
  1134.                 {
  1135.                     XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1136.                            (unsigned int) (bx - ax),
  1137.                           (unsigned int) (by - ay));
  1138.                     XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1139.                     XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1140.                 }
  1141.                 ax = zoomx + (float) h;
  1142.                 ay = zoomy + (float) v;
  1143.                 bx = zoomh + (float) h;
  1144.                 by = zoomv + (float) v;
  1145.  
  1146.                 if ((snap == True) && (raster == True))
  1147.                 {
  1148.                     snapx = (int) ax;
  1149.                     snapy = (int) ay;
  1150.                     valid_snap_coords(&snapx, &snapy);
  1151.                     bx -= (ax - (float) snapx);
  1152.                     by -= (ay - (float) snapy);
  1153.                     ax = (float) snapx;
  1154.                     ay = (float) snapy;
  1155.                 }
  1156.                 XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1157.                            (unsigned int) (bx - ax),
  1158.                            (unsigned int) (by - ay));
  1159.                 XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1160.                 XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1161.             }
  1162.             break;
  1163.  
  1164.         case 'C':
  1165.             h = x - startx;
  1166.             v = y - starty;
  1167.             if ((oldh != h) || (oldv != v))
  1168.             {
  1169.                 oldh = h;
  1170.                 oldv = v;
  1171.                 two = (struct fig2 *) obj[currIndex];
  1172.                 zoomx = two->x;
  1173.                 zoomy = two->y;
  1174.                 rad = two->radius;
  1175.                 if (zoomed == True)
  1176.                 {
  1177.                     real2zoomed(&zoomx, &zoomy);
  1178.                     real2zoomed(&zoomh, &zoomv);
  1179.                     rad *= 10;
  1180.                 }
  1181.                 if (by == -999.0)
  1182.                 {
  1183.                     XDrawArc(disp, win, gc, (int) zoomx - rad,
  1184.                          (int) zoomy - rad,
  1185.                          (unsigned int) (rad + rad),
  1186.                          (unsigned int) (rad + rad), 0, 64 * 360);
  1187.                     by = 0;
  1188.                 } else
  1189.                 {
  1190.                     XDrawArc(disp, win, gc, (int) (ax - (float) rad),
  1191.                          (int) (ay - (float) rad),
  1192.                          (unsigned int) (rad + rad),
  1193.                          (unsigned int) (rad + rad), 0, 64 * 360);
  1194.                     XDrawLine(disp, win, gc, ax, ay - rad, ax, ay + rad);
  1195.                     XDrawLine(disp, win, gc, ax - rad, ay, ax + rad, ay);
  1196.                 }
  1197.                 ax = zoomx + (float) h;
  1198.                 ay = zoomy + (float) v;
  1199.  
  1200.                 if ((snap == True) && (raster == True))
  1201.                 {
  1202.                     snapx = (int) ax;
  1203.                     snapy = (int) ay;
  1204.                     valid_snap_coords(&snapx, &snapy);
  1205.                     ax = (float) snapx;
  1206.                     ay = (float) snapy;
  1207.                 }
  1208.                 XDrawArc(disp, win, gc, (int) (ax - (float) rad),
  1209.                      (int) (ay - (float) rad),
  1210.                      (unsigned int) (rad + rad),
  1211.                    (unsigned int) (rad + rad), 0, 64 * 360);
  1212.                 XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1213.                 XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1214.             }
  1215.             break;
  1216.  
  1217.         case 'B':
  1218.             h = x - startx;
  1219.             v = y - starty;
  1220.             if ((oldh != h) || (oldv != v))
  1221.             {
  1222.                 oldh = h;
  1223.                 oldv = v;
  1224.                 two = (struct fig2 *) obj[currIndex];
  1225.                 zoomx = two->x;
  1226.                 zoomy = two->y;
  1227.                 rad = two->radius;
  1228.                 if (zoomed == True)
  1229.                 {
  1230.                     real2zoomed(&zoomx, &zoomy);
  1231.                     real2zoomed(&zoomh, &zoomv);
  1232.                     rad *= 10;
  1233.                 }
  1234.                 if (by == -999.0)
  1235.                 {
  1236.                     XFillArc(disp, win, gc, (int) zoomx - rad, (int) zoomy - rad,
  1237.                          (unsigned int) (rad + rad),
  1238.                          (unsigned int) (rad + rad), 0, 64 * 360);
  1239.                     by = 0;
  1240.                 } else
  1241.                 {
  1242.                     XDrawArc(disp, win, gc, (int) (ax - (float) rad),
  1243.                          (int) (ay - (float) rad),
  1244.                          (unsigned int) (rad + rad),
  1245.                          (unsigned int) (rad + rad), 0, 64 * 360);
  1246.                     XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1247.                     XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1248.                 }
  1249.                 ax = zoomx + (float) h;
  1250.                 ay = zoomy + (float) v;
  1251.  
  1252.                 if ((snap == True) && (raster == True))
  1253.                 {
  1254.                     snapx = (int) ax;
  1255.                     snapy = (int) ay;
  1256.                     valid_snap_coords(&snapx, &snapy);
  1257.                     ax = (float) snapx;
  1258.                     ay = (float) snapy;
  1259.                 }
  1260.                 XDrawArc(disp, win, gc, (int) (ax - (float) rad),
  1261.                      (int) (ay - (float) rad),
  1262.                      (unsigned int) (rad + rad),
  1263.                    (unsigned int) (rad + rad), 0, 64 * 360);
  1264.                 XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1265.                 XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1266.             }
  1267.             break;
  1268.  
  1269.         case 'O':
  1270.             h = x - startx;
  1271.             v = y - starty;
  1272.             if ((oldh != h) || (oldv != v))
  1273.             {
  1274.                 oldh = h;
  1275.                 oldv = v;
  1276.                 one = (struct fig1 *) obj[currIndex];
  1277.                 zoomx = one->x;
  1278.                 zoomy = one->y;
  1279.                 zoomh = one->h;
  1280.                 zoomv = one->v;
  1281.                 if (zoomed == True)
  1282.                 {
  1283.                     real2zoomed(&zoomx, &zoomy);
  1284.                     real2zoomed(&zoomh, &zoomv);
  1285.                 }
  1286.                 if (by == -999.0)
  1287.                     DrawOval((int) zoomx, (int) zoomy, (int) zoomh, (int) zoomv);
  1288.                 else
  1289.                 {
  1290.                     DrawOval((int) ax, (int) ay, (int) bx, (int) by);
  1291.                     XDrawLine(disp, win, gc, (int) (ax + (bx - ax) / 2), (int) ay, (int) (ax + (bx - ax) / 2), by);
  1292.                     XDrawLine(disp, win, gc, (int) ax, (int) (ay + (by - ay) / 2), (int) bx, (int) (ay + (by - ay) / 2));
  1293.                 }
  1294.                 ax = zoomx + (float) h;
  1295.                 ay = zoomy + (float) v;
  1296.                 bx = zoomh + (float) h;
  1297.                 by = zoomv + (float) v;
  1298.  
  1299.                 if ((snap == True) && (raster == True))
  1300.                 {
  1301.                     snapx = (int) ax;
  1302.                     snapy = (int) ay;
  1303.                     valid_snap_coords(&snapx, &snapy);
  1304.                     bx -= (ax - (float) snapx);
  1305.                     by -= (ay - (float) snapy);
  1306.                     ax = (float) snapx;
  1307.                     ay = (float) snapy;
  1308.                 }
  1309.                 DrawOval((int) ax, (int) ay, (int) bx, (int) by);
  1310.                 XDrawLine(disp, win, gc, (int) (ax + (bx - ax) / 2), (int) ay, (int) (ax + (bx - ax) / 2), by);
  1311.                 XDrawLine(disp, win, gc, (int) ax, (int) (ay + (by - ay) / 2), (int) bx, (int) (ay + (by - ay) / 2));
  1312.             }
  1313.             break;
  1314.  
  1315.         default:
  1316.             break;
  1317.  
  1318.         }    /* switch */
  1319.     } while ((mask & btn2));    /* || ( (graph_action=='Y') && (mask & btn1) ) ); */
  1320.  
  1321.  
  1322.     if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  1323.     {    /* cancel */
  1324.         if ((refr_auto == True) && (graph_action != 'Y'))
  1325.             refresh(pboard, '?', (caddr_t)DUMMY);
  1326.         return -1;
  1327.     }
  1328.     /* store the new position of the object */
  1329.  
  1330.     switch (kind[currIndex])
  1331.     {
  1332.     case 'I':
  1333.         six = (struct fig6 *) obj[currIndex];
  1334.         if (zoomed == True) zoomed2real(&sx, &sy);
  1335.         six->ax = ax;
  1336.         six->ay = ay;
  1337.         six->ex = bx;
  1338.         six->ey = by;
  1339.         six->sx = sx;
  1340.         six->sy = sy;
  1341.         break;
  1342.  
  1343.     case 'L':
  1344.         two = (struct fig2 *) obj[currIndex];
  1345.         if (zoomed == True)
  1346.         {
  1347.             zoomed2real(&ax, &ay);
  1348.             zoomed2real(&bx, &by);
  1349.         }
  1350.         two->x = ax;
  1351.         two->y = ay;
  1352.         two->h = bx;
  1353.         two->v = by;
  1354.         break;
  1355.  
  1356.     case 'V':
  1357.         two = (struct fig2 *) obj[currIndex];
  1358.         if (zoomed == True)
  1359.         {
  1360.             zoomed2real(&ax, &ay);
  1361.             zoomed2real(&bx, &by);
  1362.         }
  1363.         two->x = ax;
  1364.         two->y = ay;
  1365.         two->h = bx;
  1366.         two->v = by;
  1367.         break;
  1368.  
  1369.  
  1370.     case 'N':
  1371.         three = (struct fig3 *) obj[currIndex];
  1372.         XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1373.         XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1374.         zoomx = ax;
  1375.         zoomy = ay;
  1376.         zoomh = bx;
  1377.         zoomv = by;
  1378.         if (zoomed == True)
  1379.         {
  1380.             zoomed2real(&zoomx, &zoomy);
  1381.             zoomed2real(&zoomh, &zoomv);
  1382.         }
  1383.         three->x = zoomx;
  1384.         three->y = zoomy;
  1385.         three->h = zoomh;
  1386.         three->v = zoomv;
  1387.         print_box_text(three->textpos, zoomx, zoomy, zoomh, zoomv, three->text);
  1388.         break;
  1389.  
  1390.     case 'D':
  1391.         four = (struct fig4 *) obj[currIndex];
  1392.         XSetLineAttributes(disp, gc, 0, LineOnOffDash, CapButt, JoinMiter);
  1393.         XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1394.         XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1395.         XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  1396.         zoomx = ax;
  1397.         zoomy = ay;
  1398.         zoomh = bx;
  1399.         zoomv = by;
  1400.         if (zoomed == True)
  1401.         {
  1402.             zoomed2real(&zoomx, &zoomy);
  1403.             zoomed2real(&zoomh, &zoomv);
  1404.         }
  1405.         four->x = zoomx;
  1406.         four->y = zoomy;
  1407.         four->h = zoomh;
  1408.         four->v = zoomv;
  1409.         print_box_text(four->textpos, zoomx, zoomy, zoomh, zoomv, four->text);
  1410.         break;
  1411.  
  1412.     case 'F':
  1413.         two = (struct fig2 *) obj[currIndex];
  1414.         XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1415.         XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1416.         XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1417.                    (unsigned int) (bx - ax),
  1418.                    (unsigned int) (by - ay));
  1419.         XFillRectangle(disp, win, gc, (int) ax, (int) ay,
  1420.                    (unsigned int) (bx - ax),
  1421.                    (unsigned int) (by - ay));
  1422.         zoomx = ax;
  1423.         zoomy = ay;
  1424.         zoomh = bx;
  1425.         zoomv = by;
  1426.         if (zoomed == True)
  1427.         {
  1428.             zoomed2real(&zoomx, &zoomy);
  1429.             zoomed2real(&zoomh, &zoomv);
  1430.         }
  1431.         two->x = zoomx;
  1432.         two->y = zoomy;
  1433.         two->h = zoomh;
  1434.         two->v = zoomv;
  1435.         break;
  1436.  
  1437.     case 'C':
  1438.         two = (struct fig2 *) obj[currIndex];
  1439.         XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1440.         XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1441.         zoomx = ax;
  1442.         zoomy = ay;
  1443.         if (zoomed == True)
  1444.         {
  1445.             zoomed2real(&zoomx, &zoomy);
  1446.             zoomed2real(&zoomh, &zoomv);
  1447.         }
  1448.         two->x = zoomx;
  1449.         two->y = zoomy;
  1450.         break;
  1451.  
  1452.     case 'B':
  1453.         two = (struct fig2 *) obj[currIndex];
  1454.         XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1455.         XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1456.         XDrawArc(disp, win, gc, (int) ax - rad, (int) ay - rad,
  1457.              (unsigned int) (rad + rad),
  1458.              (unsigned int) (rad + rad), 0, 64 * 360);
  1459.         XFillArc(disp, win, gc, (int) ax - rad, (int) ay - rad,
  1460.              (unsigned int) (rad + rad),
  1461.              (unsigned int) (rad + rad), 0, 64 * 360);
  1462.         zoomx = ax;
  1463.         zoomy = ay;
  1464.         if (zoomed == True)
  1465.         {
  1466.             zoomed2real(&zoomx, &zoomy);
  1467.             zoomed2real(&zoomh, &zoomv);
  1468.         }
  1469.         two->x = zoomx;
  1470.         two->y = zoomy;
  1471.         break;
  1472.  
  1473.     case 'O':
  1474.         one = (struct fig1 *) obj[currIndex];
  1475.         XDrawLine(disp, win, gc, (int) (ax + (bx - ax) / 2), (int) ay,
  1476.               (int) (ax + (bx - ax) / 2), (int) by);
  1477.         XDrawLine(disp, win, gc, (int) ax, (int) (ay + (by - ay) / 2),
  1478.               (int) bx, (int) (ay + (by - ay) / 2));
  1479.         zoomx = ax;
  1480.         zoomy = ay;
  1481.         zoomh = bx;
  1482.         zoomv = by;
  1483.         if (zoomed == True)
  1484.         {
  1485.             zoomed2real(&zoomx, &zoomy);
  1486.             zoomed2real(&zoomh, &zoomv);
  1487.         }
  1488.         one->x = zoomx;
  1489.         one->y = zoomy;
  1490.         one->h = zoomh;
  1491.         one->v = zoomv;
  1492.         break;
  1493.  
  1494.  
  1495.     default:
  1496.         break;
  1497.  
  1498.     }    /* switch */
  1499.  
  1500.  
  1501.  
  1502.  
  1503.     if (refr_auto == True)
  1504.         refresh(pboard, '?', (caddr_t)DUMMY);
  1505.  
  1506.     return 0;
  1507.  
  1508.  
  1509. }
  1510.  
  1511.  
  1512. void
  1513. pick_edit()
  1514. {
  1515.     /* currIndex points to object-reference in global database */
  1516.     /* button 1 is pressed */
  1517.  
  1518.     struct fig1    *one;
  1519.     struct fig2    *two;
  1520.     struct fig3    *three;
  1521.     struct fig4    *four;
  1522.     struct fig6    *six;
  1523.     int             x, y, dist1, dist2, dist3, dist4, low_val;
  1524.     unsigned int    mask;
  1525.     double          vec_x, vec_y, vec_h, vec_v;
  1526.     int             res1, res2;
  1527.     float           h_pos, v_pos, x_pos, y_pos;
  1528.     float           h, v;
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.     PointerPosition(&x, &y, &mask);
  1535.  
  1536.  
  1537.     if (zoomed == True)
  1538.     {
  1539.         h = (float) x;
  1540.         v = (float) y;
  1541.         zoomed2real(&h, &v);
  1542.         x = (int) h;
  1543.         y = (int) v;
  1544.     }
  1545.     switch (kind[currIndex])
  1546.     {
  1547.     case 'I':    /* which point ? */
  1548.         six = (struct fig6 *) obj[currIndex];
  1549.         dist1 = calc_distance(x, y, (int) six->ax, (int) six->ay);    /* ax,ay */
  1550.         dist2 = calc_distance(x, y, (int) six->ex, (int) six->ey);    /* ex,ey */
  1551.         dist3 = calc_distance(x, y, (int) six->sx, (int) six->sy);    /* sx,sy */
  1552.         if (zoomed == True)
  1553.         {
  1554.             dist1 *= 10;
  1555.             dist2 *= 10;
  1556.             dist3 *= 10;
  1557.         }
  1558.         /* compute minimum */
  1559.         low_val=(dist1<dist2) ? dist1 : dist2;
  1560.         low_val=(low_val<dist3) ? low_val : dist3;
  1561.         if (low_val<=points)
  1562.         { /* buttonpress was inside of circle */
  1563.         if (low_val==dist1) edit_bezier_curveA();
  1564.             else if (low_val==dist2) edit_bezier_curveE();
  1565.             else edit_bezier_curveS();    
  1566.  
  1567.             if (refr_auto == True)
  1568.                 refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1569.         }    /* if low_val<=points */
  1570.         break;
  1571.  
  1572.     case 'L':    /* edit which endpoint ? */
  1573.         two = (struct fig2 *) obj[currIndex];
  1574.         vec_x = (double) two->x - (double) x;
  1575.         vec_y = (double) two->y - (double) y;
  1576.         vec_h = (double) two->h - (double) x;
  1577.         vec_v = (double) two->v - (double) y;
  1578.         res1 = abs((int) sqrt(vec_x * vec_x + vec_y * vec_y));
  1579.         res2 = abs((int) sqrt(vec_h * vec_h + vec_v * vec_v));
  1580.         if (zoomed == True)
  1581.         {
  1582.             res1 = res1 * 10;
  1583.             res2 = res2 * 10;
  1584.         }
  1585.         if ((res1 <= points) || (res2 <= points))
  1586.         {
  1587.             if (res1 < res2)
  1588.             {
  1589.                 edit_x_line();
  1590.                 if (refr_auto == True)
  1591.                     refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1592.             } else
  1593.             {
  1594.                 edit_y_line();
  1595.                 if (refr_auto == True)
  1596.                     refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1597.             }
  1598.         }
  1599.         break;
  1600.  
  1601.     case 'V':    /* edit which endpoint ? */
  1602.         two = (struct fig2 *) obj[currIndex];
  1603.         vec_x = (double) two->x - (double) x;
  1604.         vec_y = (double) two->y - (double) y;
  1605.         vec_h = (double) two->h - (double) x;
  1606.         vec_v = (double) two->v - (double) y;
  1607.         res1 = abs((int) sqrt(vec_x * vec_x + vec_y * vec_y));
  1608.         res2 = abs((int) sqrt(vec_h * vec_h + vec_v * vec_v));
  1609.         if (zoomed == True)
  1610.         {
  1611.             res1 = res1 * 10;
  1612.             res2 = res2 * 10;
  1613.         }
  1614.         if ((res1 <= points) || (res2 <= points))
  1615.         {
  1616.             if (res1 < res2)
  1617.                 edit_x_vector();
  1618.             else
  1619.                 edit_y_vector();
  1620.         }
  1621.         break;
  1622.  
  1623.     case 'N':    /* which point ? */
  1624.         three = (struct fig3 *) obj[currIndex];
  1625.         dist1 = calc_distance(x, y, (int) three->x, (int) three->y);    /* upper left */
  1626.         dist2 = calc_distance(x, y, (int) three->h, (int) three->v);    /* lower right */
  1627.         dist3 = calc_distance(x, y, (int) three->h, (int) three->y);    /* upper right */
  1628.         dist4 = calc_distance(x, y, (int) three->x, (int) three->v);    /* lower left */
  1629.         if (zoomed == True)
  1630.         {
  1631.             dist1 *= 10;
  1632.             dist2 *= 10;
  1633.             dist3 *= 10;
  1634.             dist4 *= 10;
  1635.         }
  1636.         /* compute minimum */
  1637.         if (dist1 < dist2)
  1638.             low_val = dist1;
  1639.         else
  1640.             low_val = dist2;
  1641.         if (dist3 < low_val)
  1642.             low_val = dist3;
  1643.         if (dist4 < low_val)
  1644.             low_val = dist4;
  1645.         if (low_val <= points)
  1646.         {
  1647.             x_pos = three->x;
  1648.             y_pos = three->y;
  1649.             h_pos = three->h;
  1650.             v_pos = three->v;
  1651.             if (low_val == dist1)
  1652.             {
  1653.                 three->x = h_pos;
  1654.                 three->y = v_pos;
  1655.                 three->h = x_pos;
  1656.                 three->v = y_pos;
  1657.                 /*
  1658.                  * now, coordinates are in the correct
  1659.                  * order...
  1660.                  */
  1661.             } else if (low_val == dist3)
  1662.             {
  1663.                 three->y = v_pos;
  1664.                 three->v = y_pos;
  1665.             } else if (low_val == dist4)
  1666.             {
  1667.                 three->x = h_pos;
  1668.                 three->h = x_pos;
  1669.             }
  1670.             /* low_val==dist2 is default... */
  1671.             edit_frame(nn);
  1672.             if (refr_auto == True)
  1673.                 refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1674.         }    /* if low_val<=points */
  1675.         break;
  1676.  
  1677.  
  1678.     case 'F':    /* which point ? */
  1679.         two = (struct fig2 *) obj[currIndex];
  1680.         dist1 = calc_distance(x, y, (int) two->x, (int) two->y);    /* upper left */
  1681.         dist2 = calc_distance(x, y, (int) two->h, (int) two->v);    /* lower right */
  1682.         dist3 = calc_distance(x, y, (int) two->h, (int) two->y);    /* upper right */
  1683.         dist4 = calc_distance(x, y, (int) two->x, (int) two->v);    /* lower left */
  1684.         if (zoomed == True)
  1685.         {
  1686.             dist1 *= 10;
  1687.             dist2 *= 10;
  1688.             dist3 *= 10;
  1689.             dist4 *= 10;
  1690.         }
  1691.         /* compute minimum */
  1692.         if (dist1 < dist2)
  1693.             low_val = dist1;
  1694.         else
  1695.             low_val = dist2;
  1696.         if (dist3 < low_val)
  1697.             low_val = dist3;
  1698.         if (dist4 < low_val)
  1699.             low_val = dist4;
  1700.         if (low_val <= points)
  1701.         {
  1702.             x_pos = two->x;
  1703.             y_pos = two->y;
  1704.             h_pos = two->h;
  1705.             v_pos = two->v;
  1706.             if (low_val == dist1)
  1707.             {
  1708.                 two->x = h_pos;
  1709.                 two->y = v_pos;
  1710.                 two->h = x_pos;
  1711.                 two->v = y_pos;
  1712.                 /*
  1713.                  * now, coordinates are in the correct
  1714.                  * order...
  1715.                  */
  1716.             } else if (low_val == dist3)
  1717.             {
  1718.                 two->y = v_pos;
  1719.                 two->v = y_pos;
  1720.             } else if (low_val == dist4)
  1721.             {
  1722.                 two->x = h_pos;
  1723.                 two->h = x_pos;
  1724.             }
  1725.             /* low_val==dist2 is default... */
  1726.             edit_frame(ff);
  1727.             if (refr_auto == True)
  1728.                 refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1729.         }    /* if low_val<=points */
  1730.         break;
  1731.  
  1732.  
  1733.  
  1734.     case 'D':    /* which point ? */
  1735.         four = (struct fig4 *) obj[currIndex];
  1736.         dist1 = calc_distance(x, y, (int) four->x, (int) four->y);    /* upper left */
  1737.         dist2 = calc_distance(x, y, (int) four->h, (int) four->v);    /* lower right */
  1738.         dist3 = calc_distance(x, y, (int) four->h, (int) four->y);    /* upper right */
  1739.         dist4 = calc_distance(x, y, (int) four->x, (int) four->v);    /* lower left */
  1740.         if (zoomed == True)
  1741.         {
  1742.             dist1 *= 10;
  1743.             dist2 *= 10;
  1744.             dist3 *= 10;
  1745.             dist4 *= 10;
  1746.         }
  1747.         /* compute minimum */
  1748.         if (dist1 < dist2)
  1749.             low_val = dist1;
  1750.         else
  1751.             low_val = dist2;
  1752.         if (dist3 < low_val)
  1753.             low_val = dist3;
  1754.         if (dist4 < low_val)
  1755.             low_val = dist4;
  1756.         if (low_val <= points)
  1757.         {
  1758.             x_pos = four->x;
  1759.             y_pos = four->y;
  1760.             h_pos = four->h;
  1761.             v_pos = four->v;
  1762.             if (low_val == dist1)
  1763.             {
  1764.                 four->x = h_pos;
  1765.                 four->y = v_pos;
  1766.                 four->h = x_pos;
  1767.                 four->v = y_pos;
  1768.                 /*
  1769.                  * now, coordinates are in the correct
  1770.                  * order...
  1771.                  */
  1772.             } else if (low_val == dist3)
  1773.             {
  1774.                 four->y = v_pos;
  1775.                 four->v = y_pos;
  1776.             } else if (low_val == dist4)
  1777.             {
  1778.                 four->x = h_pos;
  1779.                 four->h = x_pos;
  1780.             }
  1781.             /* low_val==dist2 is default... */
  1782.             edit_frame(dd);
  1783.             if (refr_auto == True)
  1784.                 refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1785.         }    /* if low_val<=points */
  1786.         break;
  1787.  
  1788.     case 'O':    /* which point ? */
  1789.         one = (struct fig1 *) obj[currIndex];
  1790.         dist1 = calc_distance(x, y, (int) one->x, (int) one->y);    /* upper left */
  1791.         dist2 = calc_distance(x, y, (int) one->h, (int) one->v);    /* lower right */
  1792.         dist3 = calc_distance(x, y, (int) one->h, (int) one->y);    /* upper right */
  1793.         dist4 = calc_distance(x, y, (int) one->x, (int) one->v);    /* lower left */
  1794.         if (zoomed == True)
  1795.         {
  1796.             dist1 *= 10;
  1797.             dist2 *= 10;
  1798.             dist3 *= 10;
  1799.             dist4 *= 10;
  1800.         }
  1801.         /* compute minimum */
  1802.         if (dist1 < dist2)
  1803.             low_val = dist1;
  1804.         else
  1805.             low_val = dist2;
  1806.         if (dist3 < low_val)
  1807.             low_val = dist3;
  1808.         if (dist4 < low_val)
  1809.             low_val = dist4;
  1810.         if (low_val <= points)
  1811.         {
  1812.             x_pos = one->x;
  1813.             y_pos = one->y;
  1814.             h_pos = one->h;
  1815.             v_pos = one->v;
  1816.             if (low_val == dist1)
  1817.             {
  1818.                 one->x = h_pos;
  1819.                 one->y = v_pos;
  1820.                 one->h = x_pos;
  1821.                 one->v = y_pos;
  1822.                 /*
  1823.                  * now, coordinates are in the correct
  1824.                  * order...
  1825.                  */
  1826.             } else if (low_val == dist3)
  1827.             {
  1828.                 one->y = v_pos;
  1829.                 one->v = y_pos;
  1830.             } else if (low_val == dist4)
  1831.             {
  1832.                 one->x = h_pos;
  1833.                 one->h = x_pos;
  1834.             }
  1835.             /* low_val==dist2 is default... */
  1836.             edit_frame(oo);
  1837.             if (refr_auto == True)
  1838.                 refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1839.         }    /* if low_val<=points */
  1840.         break;
  1841.  
  1842.     case 'C':
  1843.         low_val = valid_circle_edit(x, y);
  1844.         if (zoomed == True)
  1845.             low_val *= 10;
  1846.         if (low_val <= points)
  1847.         {
  1848.             edit_circle(cc);
  1849.             if (refr_auto == True)
  1850.                 refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1851.         }
  1852.         break;
  1853.  
  1854.     case 'B':
  1855.         low_val = valid_circle_edit(x, y);
  1856.         if (zoomed == True)
  1857.             low_val *= 10;
  1858.         if (low_val <= points)
  1859.         {
  1860.             edit_circle(bb);
  1861.             if (refr_auto == True)
  1862.                 refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1863.         }
  1864.         break;
  1865.  
  1866.  
  1867.  
  1868.     default:
  1869.         break;
  1870.  
  1871.     }    /* switch */
  1872. }/* pick_edit */
  1873.  
  1874.  
  1875. int
  1876. valid_circle_edit(int x, int y)
  1877. {
  1878.     struct fig2    *two;
  1879.     int             dist;
  1880.     two = (struct fig2 *) obj[currIndex];
  1881.  
  1882.     dist = calc_distance((int) two->x, (int) two->y, x, y);
  1883.  
  1884.     return abs(dist - two->radius);
  1885. }
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891. void
  1892. edit_circle(char ch)
  1893. {
  1894.     struct fig2    *two;
  1895.     int             x, y, rad, zoom, rad2, oldrad;
  1896.     unsigned int    mask;
  1897.     Display        *disp = XtDisplay(pboard);
  1898.     Window          win = XtWindow(pboard);
  1899.     int             btn1 = 256, btn2 = 512, btn3 = 1024;
  1900.  
  1901.  
  1902.     two = (struct fig2 *) obj[currIndex];
  1903.  
  1904.     oldrad = two->radius;
  1905.  
  1906.  
  1907.     if (zoomed == True)
  1908.     {
  1909.         real2zoomed(&two->x, &two->y);
  1910.         zoom = 10;
  1911.     } else
  1912.         zoom = 1;
  1913.  
  1914.  
  1915.  
  1916.     do
  1917.     {
  1918.         PointerPosition(&x, &y, &mask);
  1919.  
  1920.         /* delete old */
  1921.         rad = two->radius;
  1922.         if (ch == 'C')
  1923.             valid_kreis_coords((int) (two->x), (int) (two->y), &x, &y, &rad2);
  1924.         else
  1925.             valid_disc_coords((int) (two->x), (int) (two->y), &x, &y, &rad2);
  1926.  
  1927.         if (rad2 != rad)
  1928.         {    /* redraw necessary */
  1929.  
  1930.  
  1931.             draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  1932.  
  1933.             if (ch == 'C')
  1934.                 XDrawArc(disp, win, gc,
  1935.                      (int) (two->x) - (rad * zoom), (int) (two->y) - (rad * zoom),
  1936.                      (unsigned int) (zoom * (rad + rad)),
  1937.                      (unsigned int) (zoom * (rad + rad)), 0, 360 * 64);
  1938.             else
  1939.                 XFillArc(disp, win, gc,
  1940.                      (int) (two->x) - (rad * zoom), (int) (two->y) - (rad * zoom),
  1941.                      (unsigned int) (zoom * (rad + rad)),
  1942.                      (unsigned int) (zoom * (rad + rad)), 0, 360 * 64);
  1943.  
  1944.             rad = rad2;
  1945.             two->radius = rad;
  1946.             if (ch == 'C')
  1947.                 XDrawArc(disp, win, gc,
  1948.                      (int) (two->x) - (rad * zoom), (int) (two->y) - (rad * zoom),
  1949.                      (unsigned int) (zoom * (rad + rad)),
  1950.                      (unsigned int) (zoom * (rad + rad)), 0, 360 * 64);
  1951.             else
  1952.                 XFillArc(disp, win, gc,
  1953.                      (int) (two->x) - (rad * zoom), (int) (two->y) - (rad * zoom),
  1954.                      (unsigned int) (zoom * (rad + rad)),
  1955.                      (unsigned int) (zoom * (rad + rad)), 0, 360 * 64);
  1956.  
  1957.         }    /* redraw necessary */
  1958.     } while (mask & btn1);
  1959.  
  1960.  
  1961.     if (zoomed == True)
  1962.         zoomed2real(&two->x, &two->y);
  1963.  
  1964.     if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  1965.     {    /* cancel */
  1966.         two->radius = oldrad;
  1967.         return;
  1968.     }
  1969. }
  1970.  
  1971.  
  1972. void
  1973. edit_bezier_curveA()
  1974. {
  1975.   struct fig6 *six=(struct fig6 *) obj[currIndex];
  1976.   float sx,sy;
  1977.   float x_old;
  1978.   float y_old;
  1979.   Display *disp=XtDisplay(pboard);
  1980.   Window win=XtWindow(pboard);
  1981.   int x,y;
  1982.   unsigned int mask;
  1983.   int btn1=256, btn2=512, btn3=1024;
  1984.   float help1,help2;
  1985.  
  1986.  
  1987.     sx=six->sx;
  1988.     sy=six->sy;
  1989.  
  1990.     if (zoomed==True) real2zoomed(&sx,&sy);
  1991.  
  1992.     x_old=six->ax;
  1993.     y_old=six->ay;
  1994.  
  1995.     do
  1996.     {
  1997.         snapPointerPosition(&x, &y, &mask);
  1998.         
  1999.         if (zoomed==True)
  2000.             {
  2001.                 help1=(float)x;
  2002.                 help2=(float)y;
  2003.                 zoomed2real(&help1,&help2);
  2004.                 x=(int)help1;
  2005.                 y=(int)help2;
  2006.             }
  2007.         
  2008.         if ((x != (int)x_old) || (y != (int)y_old)) 
  2009.         {    /* redraw necessary */
  2010.             draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  2011.  
  2012.             
  2013.  
  2014.             /* delete old object */
  2015.             
  2016.             DrawBezier(x_old,y_old,six->ex,six->ey,sx,sy);
  2017.  
  2018.             x_old=(float)x;
  2019.             y_old=(float)y;
  2020.  
  2021.             /* draw new */
  2022.  
  2023.             DrawBezier(x_old,y_old,six->ex,six->ey,sx,sy);
  2024.  
  2025.         }  /* redraw */
  2026.  
  2027.     } while (mask & btn1);
  2028.  
  2029.     /* btn1 was released... */
  2030.     /* cancel, if pointer is outside of pboard */
  2031.  
  2032.     if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))    /* cancel */
  2033.         return;
  2034.  
  2035.  
  2036.     /* save new coordinates & translate them to the right mode */
  2037.     /* new coordinate is in x_old,y_old */
  2038.  
  2039.     six->ax=x_old;
  2040.     six->ay=y_old;
  2041. }
  2042.  
  2043.  
  2044.  
  2045. void edit_bezier_curveE()
  2046. {
  2047.   struct fig6 *six=(struct fig6 *) obj[currIndex];
  2048.   float sx,sy;
  2049.   float x_old;
  2050.   float y_old;
  2051.   Display *disp=XtDisplay(pboard);
  2052.   Window win=XtWindow(pboard);
  2053.   int x,y;
  2054.   unsigned int mask;
  2055.   int btn1=256,btn2=512,btn3=1024;
  2056.   float help1,help2;
  2057.  
  2058.  
  2059.     sx=six->sx;
  2060.     sy=six->sy;
  2061.  
  2062.     if (zoomed==True) real2zoomed(&sx,&sy);
  2063.  
  2064.     x_old=six->ex;
  2065.     y_old=six->ey;
  2066.  
  2067.     do
  2068.     {
  2069.         snapPointerPosition(&x, &y, &mask);
  2070.         if (zoomed==True)
  2071.         {
  2072.             help1=(float)x;
  2073.             help2=(float)y;
  2074.             zoomed2real(&help1,&help2);
  2075.             x=(int)help1;
  2076.             y=(int)help2;
  2077.         }
  2078.         if ((x != (int)x_old) || (y != (int)y_old))
  2079.         {    /* redraw necessary */
  2080.             draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  2081.  
  2082.             /* delete old object */
  2083.             
  2084.             DrawBezier(six->ax,six->ay,x_old,y_old,sx,sy);
  2085.  
  2086.             x_old=(float)x;
  2087.             y_old=(float)y;
  2088.  
  2089.             /* draw new */
  2090.  
  2091.             DrawBezier(six->ax,six->ay,x_old,y_old,sx,sy);
  2092.  
  2093.         } /* redraw */
  2094.  
  2095.     } while (mask & btn1);
  2096.  
  2097.     /* btn1 was released... */
  2098.     /* cancel, if pointer is outside of pboard */
  2099.  
  2100.     if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))    /* cancel */
  2101.         return;
  2102.  
  2103.  
  2104.     /* save new coordinates & translate them to the right mode */
  2105.     /* new coordinate is in x_old,y_old */
  2106.  
  2107.     six->ex=x_old;
  2108.     six->ey=y_old;
  2109. }
  2110.  
  2111.  
  2112. void edit_bezier_curveS()
  2113. {
  2114.   struct fig6 *six=(struct fig6 *) obj[currIndex];
  2115.   float sx,sy;
  2116.   float x_old;
  2117.   float y_old;
  2118.   Display *disp=XtDisplay(pboard);
  2119.   Window win=XtWindow(pboard);
  2120.   int x,y;
  2121.   unsigned int mask;
  2122.   int btn1=256,btn2=512,btn3=1024;
  2123.   
  2124.  
  2125.     
  2126.  
  2127.     
  2128.  
  2129.     x_old=six->sx;
  2130.     y_old=six->sy;
  2131.  
  2132.     if (zoomed==True) real2zoomed(&x_old,&y_old);
  2133.  
  2134.     do
  2135.     {
  2136.         snapPointerPosition(&x, &y, &mask);
  2137.         if ((x != (int)x_old) || (y != (int)y_old))
  2138.         {    /* redraw necessary */
  2139.             draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  2140.  
  2141.             /* delete old object */
  2142.             
  2143.             DrawBezier(six->ax,six->ay,six->ex,six->ey,x_old,y_old);
  2144.  
  2145.             x_old=(float)x;
  2146.             y_old=(float)y;
  2147.  
  2148.             /* draw new */
  2149.  
  2150.             DrawBezier(six->ax,six->ay,six->ex,six->ey,x_old,y_old);
  2151.  
  2152.         } /* redraw */
  2153.  
  2154.     } while (mask & btn1);
  2155.  
  2156.     /* btn1 was released... */
  2157.     /* cancel, if pointer is outside of pboard */
  2158.  
  2159.     if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))    /* cancel */
  2160.         return;
  2161.  
  2162.  
  2163.     /* save new coordinates & translate them to the right mode */
  2164.     /* new coordinate is in x_old,y_old */
  2165.  
  2166.     if (zoomed==True) zoomed2real(&x_old,&y_old);
  2167.  
  2168.     six->sx=x_old;
  2169.     six->sy=y_old;
  2170. }
  2171.  
  2172.  
  2173. void
  2174. edit_frame(char ch)
  2175. {
  2176.     struct fig1    *one;
  2177.     struct fig2    *two;
  2178.     struct fig3    *three;
  2179.     struct fig4    *four;
  2180.     unsigned int    mask;
  2181.     Display        *disp = XtDisplay(pboard);
  2182.     Window          win = XtWindow(pboard);
  2183.     int             btn1 = 256, btn2 = 512, btn3 = 1024;
  2184.     float           x1, x2, y1, y2, y1old, y2old;
  2185.     float           x11, x22, y11, y22;
  2186.     int             x, y;
  2187.     y22 = 999.0;
  2188.  
  2189.     switch (ch)
  2190.     {
  2191.  
  2192.     case 'N':
  2193.         three = (struct fig3 *) obj[currIndex];
  2194.         x1 = three->x;
  2195.         x2 = three->y;
  2196.         y1 = three->h;
  2197.         y2 = three->v;
  2198.         break;
  2199.  
  2200.     case 'D':
  2201.         four = (struct fig4 *) obj[currIndex];
  2202.         x1 = four->x;
  2203.         x2 = four->y;
  2204.         y1 = four->h;
  2205.         y2 = four->v;
  2206.         break;
  2207.  
  2208.     case 'F':
  2209.         two = (struct fig2 *) obj[currIndex];
  2210.         x1 = two->x;
  2211.         x2 = two->y;
  2212.         y1 = two->h;
  2213.         y2 = two->v;
  2214.         break;
  2215.  
  2216.     case 'O':
  2217.         one = (struct fig1 *) obj[currIndex];
  2218.         x1 = one->x;
  2219.         x2 = one->y;
  2220.         y1 = one->h;
  2221.         y2 = one->v;
  2222.         break;
  2223.  
  2224.     default:
  2225.         break;
  2226.  
  2227.     }    /* switch */
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.     /* x=(x1,x2)  y=(y1,y2) */
  2234.  
  2235.     /* save y-coordinate */
  2236.     y1old = y1;
  2237.     y2old = y2;
  2238.  
  2239.  
  2240.     if (zoomed == True)
  2241.     {
  2242.         real2zoomed(&x1, &x2);
  2243.         real2zoomed(&y1, &y2);
  2244.     }
  2245.     /* (x1,x2) is a fixed point, 'edit' influences (y1,y2) only */
  2246.  
  2247.  
  2248.  
  2249.     do
  2250.     {
  2251.         snapPointerPosition(&x, &y, &mask);
  2252.         if ((x != y1) || (y != y2))
  2253.         {    /* redraw necessary */
  2254.             draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  2255.             /* delete old object */
  2256.             if (y22 == 999.0)
  2257.             {
  2258.                 y11 = y1;
  2259.                 y22 = y2;
  2260.                 x11 = x1;
  2261.                 x22 = x2;
  2262.                 norm_rectangle(&x11, &x22, &y11, &y22);
  2263.             }
  2264.             switch (ch)
  2265.             {
  2266.             case 'N':
  2267.                 XDrawRectangle(disp, win, gc, (int) x11, (int) x22,
  2268.                      (unsigned int) ((int) (y11 - x11)),
  2269.                     (unsigned int) ((int) (y22 - x22)));
  2270.                 break;
  2271.             case 'F':
  2272.                 XFillRectangle(disp, win, gc, (int) x11, (int) x22,
  2273.                      (unsigned int) ((int) (y11 - x11)),
  2274.                     (unsigned int) ((int) (y22 - x22)));
  2275.                 break;
  2276.  
  2277.  
  2278.             case 'D':
  2279.                 XSetLineAttributes(disp, gc, 0, LineOnOffDash, CapButt, JoinMiter);
  2280.                 XDrawRectangle(disp, win, gc, (int) x11, (int) x22,
  2281.                      (unsigned int) ((int) (y11 - x11)),
  2282.                     (unsigned int) ((int) (y22 - x22)));
  2283.                 XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  2284.                 break;
  2285.  
  2286.             case 'O':
  2287.                 DrawOval((int) x11, (int) x22, (int) y11, (int) y22);
  2288.                 break;
  2289.  
  2290.             default:
  2291.                 break;
  2292.  
  2293.             }    /* switch */
  2294.  
  2295.  
  2296.  
  2297.             /* draw new */
  2298.             x11 = x1;
  2299.             x22 = x2;
  2300.             y11 = (float) x;
  2301.             y22 = (float) y;
  2302.             y1 = y11;
  2303.             y2 = y22;
  2304.             norm_rectangle(&x11, &x22, &y11, &y22);
  2305.             switch (ch)
  2306.             {
  2307.             case 'N':
  2308.                 XDrawRectangle(disp, win, gc, (int) x11, (int) x22,
  2309.                      (unsigned int) ((int) (y11 - x11)),
  2310.                     (unsigned int) ((int) (y22 - x22)));
  2311.                 break;
  2312.             case 'F':
  2313.                 XFillRectangle(disp, win, gc, (int) x11, (int) x22,
  2314.                      (unsigned int) ((int) (y11 - x11)),
  2315.                     (unsigned int) ((int) (y22 - x22)));
  2316.                 break;
  2317.  
  2318.  
  2319.             case 'D':
  2320.                 XSetLineAttributes(disp, gc, 0, LineOnOffDash, CapButt, JoinMiter);
  2321.                 XDrawRectangle(disp, win, gc, (int) x11, (int) x22,
  2322.                      (unsigned int) ((int) (y11 - x11)),
  2323.                     (unsigned int) ((int) (y22 - x22)));
  2324.                 XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  2325.                 break;
  2326.  
  2327.             case 'O':
  2328.                 DrawOval((int) x11, (int) x22, (int) y11, (int) y22);
  2329.                 break;
  2330.  
  2331.             default:
  2332.                 break;
  2333.  
  2334.             }    /* switch */
  2335.  
  2336.         }    /* redraw */
  2337.     } while (mask & btn1);
  2338.  
  2339.     /* btn1 was released... */
  2340.     /* cancel, if pointer is outside of pboard */
  2341.  
  2342.     if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))    /* cancel */
  2343.         return;
  2344.  
  2345.  
  2346.     /* save new coordinates & translate them to the right mode */
  2347.  
  2348.     switch (ch)
  2349.     {
  2350.     case 'N':
  2351.         three->h = y1;
  2352.         three->v = y2;
  2353.         if (zoomed == True)
  2354.             zoomed2real(&three->h, &three->v);
  2355.         norm_rectangle(&three->x, &three->y, &three->h, &three->v);
  2356.         break;
  2357.  
  2358.     case 'D':
  2359.         four->h = y1;
  2360.         four->v = y2;
  2361.         if (zoomed == True)
  2362.             zoomed2real(&four->h, &four->v);
  2363.         norm_rectangle(&four->x, &four->y, &four->h, &four->v);
  2364.         break;
  2365.  
  2366.     case 'F':
  2367.         two->h = y1;
  2368.         two->v = y2;
  2369.         if (zoomed == True)
  2370.             zoomed2real(&two->h, &two->v);
  2371.         norm_rectangle(&two->x, &two->y, &two->h, &two->v);
  2372.         break;
  2373.  
  2374.     case 'O':
  2375.         one->h = y1;
  2376.         one->v = y2;
  2377.         if (zoomed == True)
  2378.             zoomed2real(&one->h, &one->v);
  2379.         norm_rectangle(&one->x, &one->y, &one->h, &one->v);
  2380.         break;
  2381.  
  2382.     default:
  2383.         break;
  2384.  
  2385.     }    /* switch */
  2386.  
  2387.  
  2388. }
  2389.  
  2390.  
  2391.  
  2392. int
  2393. calc_distance(int x, int y, int h, int v)
  2394. {
  2395.     double          res;
  2396.     x -= h;
  2397.     y -= v;
  2398.  
  2399.     res = (double) (x * x + y * y);
  2400.     return (int) sqrt(res);
  2401. }
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407. void
  2408. edit_x_line()
  2409. {
  2410.  
  2411.     struct fig2    *two;
  2412.     int             x, y;
  2413.     unsigned int    mask;
  2414.     Display        *disp = XtDisplay(pboard);
  2415.     Window          win = XtWindow(pboard);
  2416.     int             btn1 = 256, btn2 = 512, btn3 = 1024;
  2417.     float           xold, yold;
  2418.     float           x1, x2, y1, y2;
  2419.     two = (struct fig2 *) obj[currIndex];
  2420.  
  2421.     if (zoomed == True)
  2422.     {    /* prepare coordinates for right mode */
  2423.         real2zoomed(&two->x, &two->y);
  2424.         real2zoomed(&two->h, &two->v);
  2425.     }
  2426.     /* save coordinates */
  2427.     xold = two->x;
  2428.     yold = two->y;
  2429.  
  2430.     do
  2431.     {
  2432.         PointerPosition(&x, &y, &mask);
  2433.         /*
  2434.          * watch the correct slopes (line and vector slopes are
  2435.          * different !)
  2436.          */
  2437.         /* so, what object is selected ? line or vector ? */
  2438.         if (kind[currIndex] == 'L')
  2439.             valid_line_coords((int) two->h, (int) two->v, &x, &y);
  2440.         else
  2441.             valid_vector_coords((int) two->h, (int) two->v, &x, &y);
  2442.  
  2443.         if ((two->x != (float) x) || (two->y != (float) y))
  2444.         {    /* redraw necessary */
  2445.  
  2446.  
  2447.             draw_coords(pboard, (caddr_t) x, (caddr_t) y);    /* dummy parameters */
  2448.  
  2449.             /* delete old */
  2450.             XDrawLine(disp, win, gc, (int) two->x, (int) two->y, (int) two->h, (int) two->v);
  2451.             /* draw new */
  2452.             two->x = (float) x;
  2453.             two->y = (float) y;
  2454.             XDrawLine(disp, win, gc, (int) two->x, (int) two->y, (int) two->h, (int) two->v);
  2455.         }    /* redraw */
  2456.     } while (mask & btn1);
  2457.  
  2458.     /* btn1 was released... */
  2459.     /* cancel, if pointer is outside of pboard */
  2460.  
  2461.     if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  2462.     {    /* cancel */
  2463.         two->x = xold;
  2464.         two->y = yold;
  2465.         if (zoomed == True)
  2466.         {
  2467.             zoomed2real(&two->h, &two->v);
  2468.             zoomed2real(&two->x, &two->y);
  2469.         }
  2470.         return;
  2471.     }
  2472.     /* translate coordinates to the right mode */
  2473.  
  2474.     if (zoomed == True)
  2475.     {
  2476.         zoomed2real(&two->h, &two->v);
  2477.         zoomed2real(&two->x, &two->y);
  2478.     }
  2479. }/* edit_x_line */
  2480.  
  2481.  
  2482.  
  2483.  
  2484. void
  2485. edit_y_line()
  2486. {
  2487.     float           swap_x, swap_y;
  2488.     struct fig2    *two;
  2489.  
  2490.  
  2491.     /* swap x,y with h,v and call edit_x_line() */
  2492.  
  2493.     two = (struct fig2 *) obj[currIndex];
  2494.  
  2495.     swap_x = two->x;
  2496.     swap_y = two->y;
  2497.  
  2498.     two->x = two->h;
  2499.     two->y = two->v;
  2500.  
  2501.     two->h = swap_x;
  2502.     two->v = swap_y;
  2503.  
  2504.     edit_x_line();
  2505.  
  2506. }/* edit_y_line */
  2507.  
  2508.  
  2509.  
  2510. void
  2511. del_vector_marker(float x, float y, float h, float v)
  2512. {
  2513.     if (zoomed == True)
  2514.     {
  2515.         real2zoomed(&x, &y);
  2516.         real2zoomed(&h, &v);
  2517.     }
  2518.     draw_vector_marker(x, y, h, v);
  2519. }
  2520.  
  2521.  
  2522.  
  2523. void
  2524. edit_x_vector()
  2525. {
  2526.     struct fig2    *two;
  2527.     two = (struct fig2 *) obj[currIndex];
  2528.  
  2529.     del_vector_marker(two->x, two->y, two->h, two->v);
  2530.  
  2531.     edit_x_line();
  2532.  
  2533.     if (refr_auto == True)
  2534.         refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  2535.  
  2536. }
  2537.  
  2538.  
  2539.  
  2540. void
  2541. edit_y_vector()
  2542. {
  2543.     struct fig2    *two;
  2544.     float           x, y;
  2545.     two = (struct fig2 *) obj[currIndex];
  2546.  
  2547.     del_vector_marker(two->x, two->y, two->h, two->v);
  2548.  
  2549.     edit_y_line();
  2550.  
  2551.     /* swap coordinates */
  2552.     x = two->x;
  2553.     y = two->y;
  2554.     two->x = two->h;
  2555.     two->y = two->v;
  2556.     two->v = y;
  2557.     two->h = x;
  2558.  
  2559.     if (refr_auto == True)
  2560.         refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  2561.  
  2562.  
  2563. }
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570. /* --==--==--==--==--==--==--==--==--==-- */
  2571. void
  2572. set_pick_erase()
  2573. {
  2574.     /* Override Translation Manager */
  2575.     XtTranslations  trans_table;
  2576.     char            destination[80] = "<Btn1Down>: pick_erase()";
  2577.     static XtActionsRec actions[80] = {{"pick_erase", pick_erase}};
  2578.     XtAddActions(actions, XtNumber(actions));
  2579.     trans_table = XtParseTranslationTable(destination);
  2580.     XtOverrideTranslations(pboard, trans_table);
  2581.  
  2582. }
  2583.  
  2584.  
  2585.  
  2586. void
  2587. pick_erase()
  2588. {
  2589.     /* pointer button one was pressed */
  2590.  
  2591.  
  2592.     Display        *disp;
  2593.     Window          win;
  2594.     unsigned int    mask, mask2;
  2595.     int             h, v, x, y;
  2596.     Position        x_rel, y_rel, xx, yy;
  2597.     int             btn1 = 256, btn2 = 512, btn3 = 1024;
  2598.     PointerPosition(&x, &y, &mask);
  2599.  
  2600.     disp = XtDisplay(pboard);
  2601.     win = XtWindow(pboard);
  2602.  
  2603.     XtUninstallTranslations(pboard);
  2604.  
  2605.     set_pick_stack(x, y);
  2606.  
  2607.     while (True)
  2608.     {
  2609.         h = nextObject();
  2610.  
  2611.         if (h == -1)
  2612.         {
  2613.             left();
  2614.             leave_pick("No valid object found !");
  2615.             return;
  2616.         }
  2617.         prepare_top_stack_object();
  2618.  
  2619.         headline(toplevel, "Actions: press Button 2 to ERASE object ----- press Button 3 for MORE");
  2620.  
  2621.         do
  2622.         {    /* listen closely to button number 2! If pressed ->
  2623.              * erase object */
  2624.             PointerPosition(&x, &y, &mask);
  2625.             if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  2626.             {
  2627.                 left();
  2628.                 prepare_top_stack_object();
  2629.                 return;
  2630.             }
  2631.         } while ((!(mask & btn3)) && (!(mask & btn2)));
  2632.  
  2633.         do
  2634.         {
  2635.             PointerPosition(&x, &y, &mask2);
  2636.             if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  2637.             {
  2638.                 left();
  2639.                 prepare_top_stack_object();
  2640.                 return;
  2641.             }
  2642.         } while (mask == mask2);
  2643.  
  2644.  
  2645.         prepare_top_stack_object();
  2646.  
  2647.         if (mask & 512)
  2648.             erase_current_object();    /* yes, erase this object */
  2649.  
  2650.         /* now work with the next object on the pick-stack */
  2651.     }
  2652.  
  2653. }
  2654.  
  2655.  
  2656. void
  2657. set_dash_mode()
  2658. {
  2659.     XGCValues       gcvals;
  2660.     Display        *disp = XtDisplay(pboard);
  2661.     Window          win = XtWindow(pboard);
  2662.     XSetLineAttributes(disp, gc, 0, LineDoubleDash, CapButt, JoinMiter);
  2663.  
  2664.     gcvals.dashes = 12;
  2665.     XChangeGC(disp, gc, GCDashList, &gcvals);
  2666. }
  2667.  
  2668.  
  2669.  
  2670. void
  2671. set_normal_mode()
  2672. {
  2673.     XGCValues       gcvals;
  2674.     Display        *disp = XtDisplay(pboard);
  2675.     Window          win = XtWindow(pboard);
  2676.     XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  2677.  
  2678.     gcvals.dashes = 5;
  2679.     XChangeGC(disp, gc, GCDashList, &gcvals);
  2680. }
  2681.  
  2682.  
  2683.  
  2684. void
  2685. prepare_top_stack_object()
  2686. {
  2687.     struct fig1    *one;
  2688.     struct fig2    *two;
  2689.     struct fig3    *three;
  2690.     struct fig4    *four;
  2691.     struct fig6    *six;
  2692.     Display        *disp = XtDisplay(pboard);
  2693.     Window          win = XtWindow(pboard);
  2694.     float           x, y, h, v, a, b;
  2695.     int             rad;
  2696.  
  2697.  
  2698.  
  2699.     switch (kind[currIndex])
  2700.     {
  2701.     case 'I':
  2702.         six = (struct fig6 *) obj[currIndex];
  2703.         x = six->ax;
  2704.         y = six->ay;
  2705.         h = six->ex;
  2706.         v = six->ey;
  2707.         a = six->sx;
  2708.         b = six->sy;
  2709.         if (zoomed == True)
  2710.         {
  2711.             real2zoomed(&x, &y);
  2712.             real2zoomed(&h, &v);
  2713.             real2zoomed(&a, &b);
  2714.         }
  2715.         XDrawArc(disp, win, gc, (int) x - points, (int) y - points,
  2716.              (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2717.         XDrawArc(disp, win, gc, (int) a - points, (int) b - points,
  2718.              (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2719.         XDrawArc(disp, win, gc, (int) h - points, (int) v - points,
  2720.              (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2721.         set_dash_mode();
  2722.         XDrawLine(disp,win,gc,(int)a,(int)b,(int)h,(int)v);
  2723.         XDrawLine(disp,win,gc,(int)h,(int)v,(int)x,(int)y);
  2724.         XDrawLine(disp,win,gc,(int)x,(int)y,(int)a,(int)b);
  2725.         set_normal_mode();
  2726.         break;
  2727.  
  2728.     case 'L':
  2729.         two = (struct fig2 *) obj[currIndex];
  2730.         x = two->x;
  2731.         y = two->y;
  2732.         h = two->h;
  2733.         v = two->v;
  2734.         if (zoomed == True)
  2735.         {
  2736.             real2zoomed(&x, &y);
  2737.             real2zoomed(&h, &v);
  2738.         }
  2739.         set_dash_mode();
  2740.         XDrawLine(disp, win, gc, (int) x, (int) y, (int) h, (int) v);
  2741.         set_normal_mode();
  2742.         XDrawArc(disp, win, gc, (int) x - points, (int) y - points,
  2743.              (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2744.         XDrawArc(disp, win, gc, (int) h - points, (int) v - points,
  2745.              (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2746.         break;
  2747.  
  2748.     case 'V':
  2749.         two = (struct fig2 *) obj[currIndex];
  2750.         x = two->x;
  2751.         y = two->y;
  2752.         h = two->h;
  2753.         v = two->v;
  2754.         if (zoomed == True)
  2755.         {
  2756.             real2zoomed(&x, &y);
  2757.             real2zoomed(&h, &v);
  2758.         }
  2759.         set_dash_mode();
  2760.         XDrawLine(disp, win, gc, (int) x, (int) y, (int) h, (int) v);
  2761.         set_normal_mode();
  2762.         XDrawArc(disp, win, gc, (int) x - points, (int) y - points,
  2763.              (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2764.         XDrawArc(disp, win, gc, (int) h - points, (int) v - points,
  2765.              (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2766.         break;
  2767.  
  2768.  
  2769.     case 'N':
  2770.         three = (struct fig3 *) obj[currIndex];
  2771.         x = three->x;
  2772.         y = three->y;
  2773.         h = three->h;
  2774.         v = three->v;
  2775.         if (zoomed == True)
  2776.         {
  2777.             real2zoomed(&x, &y);
  2778.             real2zoomed(&h, &v);
  2779.         }
  2780.         set_dash_mode();
  2781.         XDrawRectangle(disp, win, gc, (int) x, (int) y,
  2782.                 (unsigned int) (h - x), (unsigned int) (v - y));
  2783.         XDrawLine(disp, win, gc, (int) x, (int) y, (int) h, (int) v);
  2784.         XDrawLine(disp, win, gc, (int) x, (int) v, (int) h, (int) y);
  2785.         set_normal_mode();
  2786.         draw_edit_marker(x, y, h, v);
  2787.         break;
  2788.  
  2789.     case 'D':
  2790.         four = (struct fig4 *) obj[currIndex];
  2791.         x = four->x;
  2792.         y = four->y;
  2793.         h = four->h;
  2794.         v = four->v;
  2795.         if (zoomed == True)
  2796.         {
  2797.             real2zoomed(&x, &y);
  2798.             real2zoomed(&h, &v);
  2799.         }
  2800.         x -= 1;
  2801.         y -= 1;
  2802.         h += 1;
  2803.         v += 1;
  2804.         set_dash_mode();
  2805.         XDrawRectangle(disp, win, gc, (int) x, (int) y,
  2806.                 (unsigned int) (h - x), (unsigned int) (v - y));
  2807.         XDrawLine(disp, win, gc, (int) x, (int) y, (int) h, (int) v);
  2808.         XDrawLine(disp, win, gc, (int) x, (int) v, (int) h, (int) y);
  2809.         set_normal_mode();
  2810.         draw_edit_marker(x, y, h, v);
  2811.         break;
  2812.  
  2813.     case 'F':
  2814.         two = (struct fig2 *) obj[currIndex];
  2815.         x = two->x;
  2816.         y = two->y;
  2817.         h = two->h;
  2818.         v = two->v;
  2819.         if (zoomed == True)
  2820.         {
  2821.             real2zoomed(&x, &y);
  2822.             real2zoomed(&h, &v);
  2823.         }
  2824.         set_dash_mode();
  2825.         XDrawRectangle(disp, win, gc, (int) x, (int) y,
  2826.                 (unsigned int) (h - x), (unsigned int) (v - y));
  2827.         XDrawLine(disp, win, gc, (int) x, (int) y, (int) h, (int) v);
  2828.         XDrawLine(disp, win, gc, (int) x, (int) v, (int) h, (int) y);
  2829.         set_normal_mode();
  2830.         draw_edit_marker(x, y, h, v);
  2831.         break;
  2832.  
  2833.     case 'C':
  2834.         two = (struct fig2 *) obj[currIndex];
  2835.         x = two->x;
  2836.         y = two->y;
  2837.         rad = two->radius;
  2838.         if (zoomed == True)
  2839.         {
  2840.             real2zoomed(&x, &y);
  2841.             rad *= 10;
  2842.         }
  2843.         set_dash_mode();
  2844.         XDrawArc(disp, win, gc, (int) x - rad, (int) y - rad,
  2845.              (unsigned int) (2 * rad), (unsigned int) (2 * rad), 0, 360 * 64);
  2846.         set_normal_mode();
  2847.  
  2848.         break;
  2849.  
  2850.     case 'B':
  2851.         two = (struct fig2 *) obj[currIndex];
  2852.         x = two->x;
  2853.         y = two->y;
  2854.         rad = two->radius;
  2855.         if (zoomed == True)
  2856.         {
  2857.             real2zoomed(&x, &y);
  2858.             rad *= 10;
  2859.         }
  2860.         rad += 5;
  2861.         set_dash_mode();
  2862.         XDrawArc(disp, win, gc, (int) x - rad, (int) y - rad,
  2863.              (unsigned int) (2 * rad), (unsigned int) (2 * rad), 0, 360 * 64);
  2864.         set_normal_mode();
  2865.         break;
  2866.  
  2867.     case 'O':
  2868.         one = (struct fig1 *) obj[currIndex];
  2869.         x = one->x;
  2870.         y = one->y;
  2871.         h = one->h;
  2872.         v = one->v;
  2873.         if (zoomed == True)
  2874.         {
  2875.             real2zoomed(&x, &y);
  2876.             real2zoomed(&h, &v);
  2877.         }
  2878.         set_dash_mode();
  2879.         DrawOval(x, y, h, v);
  2880.         set_normal_mode();
  2881.         draw_edit_marker(x, y, h, v);
  2882.         break;
  2883.  
  2884.     default:
  2885.         break;
  2886.     }    /* switch */
  2887.  
  2888.  
  2889.     set_normal_mode();
  2890.  
  2891. }
  2892.  
  2893.  
  2894.  
  2895. void
  2896. draw_edit_marker(float x, float y, float h, float v)
  2897. {
  2898.     Display        *disp = XtDisplay(pboard);
  2899.     Window          win = XtWindow(pboard);
  2900.     XDrawArc(disp, win, gc, (int) x - points, (int) y - points,
  2901.          (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2902.     XDrawArc(disp, win, gc, (int) h - points, (int) v - points,
  2903.          (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2904.     XDrawArc(disp, win, gc, (int) x - points, (int) v - points,
  2905.          (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2906.     XDrawArc(disp, win, gc, (int) h - points, (int) y - points,
  2907.          (unsigned int) (2 * points), (unsigned int) (2 * points), 0, 360 * 64);
  2908. }
  2909.  
  2910.  
  2911.  
  2912. void
  2913. erase_current_object()
  2914. {
  2915.     Display        *disp = XtDisplay(pboard);
  2916.     Window          win = XtWindow(pboard);
  2917.     struct fig1    *one;
  2918.     struct fig2    *two;
  2919.     struct fig3    *three;
  2920.     struct fig4    *four;
  2921.     struct fig6    *six;
  2922.     float           x, y, h, v;
  2923.     int             rad;
  2924.  
  2925.  
  2926.     /* the object with index currIndex is to be erased */
  2927.  
  2928.     switch (kind[currIndex])
  2929.     {
  2930.     case 'I':
  2931.         bezier_marker = (struct fig6 *) obj[currIndex];
  2932.         /* redraw object */
  2933.         if (zoomed == True) real2zoomed(&bezier_marker->sx, &bezier_marker->sy);
  2934.         
  2935.         DrawBezier(bezier_marker->ax, bezier_marker->ay,
  2936.                bezier_marker->ex, bezier_marker->ey,
  2937.                bezier_marker->sx, bezier_marker->sy);
  2938.  
  2939.         if (bezier_start == obj[currIndex])
  2940.         {    /* first entry */
  2941.             bezier_marker = (struct fig6 *) obj[currIndex];
  2942.  
  2943.             if (bezier_curr == bezier_start)
  2944.             {    /* exactly 1 entry */
  2945.  
  2946.                 bezier_start = NULL;
  2947.                 bezier_curr = NULL;
  2948.  
  2949.             } else
  2950.                 bezier_start = bezier_start->next;
  2951.  
  2952.             free(bezier_marker);
  2953.         } else
  2954.         {
  2955.             bezier_marker = bezier_start;
  2956.             do
  2957.             {
  2958.                 six = (struct fig6 *) bezier_marker;
  2959.                 /* remember the last object */
  2960.                 bezier_marker = bezier_marker->next;
  2961.  
  2962.             } while (bezier_marker != obj[currIndex]);
  2963.             /* <bezier_marker> points to the desired object and */
  2964.             /* <six> to the object before */
  2965.  
  2966.             /* last entry ? */
  2967.             if (bezier_marker == bezier_curr)
  2968.             {
  2969.                 bezier_marker = NULL;
  2970.                 free(bezier_curr);
  2971.                 bezier_curr = six;
  2972.             } else
  2973.                 /* no! the object was somewhere in the middle */
  2974.             {
  2975.                 six->next = bezier_marker->next;
  2976.                 free(bezier_marker);
  2977.             }
  2978.         }    /* else & line */
  2979.         break;
  2980.  
  2981.     case 'L':
  2982.         strich_marker = (struct fig2 *) obj[currIndex];
  2983.         /* redraw object */
  2984.         x = strich_marker->x;
  2985.         y = strich_marker->y;
  2986.         h = strich_marker->h;
  2987.         v = strich_marker->v;
  2988.         if (zoomed == True)
  2989.         {
  2990.             real2zoomed(&x, &y);
  2991.             real2zoomed(&h, &v);
  2992.         }
  2993.         XDrawLine(disp, win, gc, (int) x, (int) y, (int) h, (int) v);
  2994.  
  2995.         if (strich_start == obj[currIndex])
  2996.         {    /* first entry */
  2997.             strich_marker = (struct fig2 *) obj[currIndex];
  2998.  
  2999.             if (strich_curr == strich_start)
  3000.             {    /* exactly 1 entry */
  3001.  
  3002.                 strich_start = NULL;
  3003.                 strich_curr = NULL;
  3004.  
  3005.             } else
  3006.                 strich_start = strich_start->next;
  3007.  
  3008.             free(strich_marker);
  3009.         } else
  3010.         {
  3011.             strich_marker = strich_start;
  3012.             do
  3013.             {
  3014.                 two = (struct fig2 *) strich_marker;
  3015.                 /* remember the last object */
  3016.                 strich_marker = strich_marker->next;
  3017.  
  3018.             } while (strich_marker != obj[currIndex]);
  3019.             /* <strich_marker> points to the desired objects and */
  3020.             /* <two> to the object before */
  3021.  
  3022.             /* last entry ? */
  3023.             if (strich_marker == strich_curr)
  3024.             {
  3025.                 strich_marker = NULL;
  3026.                 free(strich_curr);
  3027.                 strich_curr = two;
  3028.             } else
  3029.                 /* no! the object was somewhere in the middle */
  3030.             {
  3031.                 two->next = strich_marker->next;
  3032.                 free(strich_marker);
  3033.             }
  3034.         }    /* else & line */
  3035.         break;
  3036.  
  3037.     case 'V':
  3038.         pfeil_marker = (struct fig2 *) obj[currIndex];
  3039.         /* redraw object */
  3040.         x = pfeil_marker->x;
  3041.         y = pfeil_marker->y;
  3042.         h = pfeil_marker->h;
  3043.         v = pfeil_marker->v;
  3044.         if (zoomed == True)
  3045.         {
  3046.             real2zoomed(&x, &y);
  3047.             real2zoomed(&h, &v);
  3048.         }
  3049.         XDrawLine(disp, win, gc, (int) x, (int) y, (int) h, (int) v);
  3050.         draw_vector_marker(x, y, h, v);
  3051.  
  3052.         if (pfeil_start == obj[currIndex])
  3053.         {    /* first entry */
  3054.             pfeil_marker = (struct fig2 *) obj[currIndex];
  3055.  
  3056.             if (pfeil_curr == pfeil_start)
  3057.             {    /* exactly 1 entry */
  3058.  
  3059.                 pfeil_start = NULL;
  3060.                 pfeil_curr = NULL;
  3061.  
  3062.             } else
  3063.                 pfeil_start = pfeil_start->next;
  3064.  
  3065.             free(pfeil_marker);
  3066.         } else
  3067.         {
  3068.             pfeil_marker = pfeil_start;
  3069.             do
  3070.             {
  3071.                 two = (struct fig2 *) pfeil_marker;
  3072.                 /* remember the last object */
  3073.                 pfeil_marker = pfeil_marker->next;
  3074.  
  3075.             } while (pfeil_marker != obj[currIndex]);
  3076.             /* <pfeil_marker> points to the desired objects and */
  3077.             /* <two> to the object before */
  3078.  
  3079.             /* last entry ? */
  3080.             if (pfeil_marker == pfeil_curr)
  3081.             {
  3082.                 pfeil_marker = NULL;
  3083.                 free(pfeil_curr);
  3084.                 pfeil_curr = two;
  3085.             } else
  3086.                 /* no! the object was somewhere in the middle */
  3087.             {
  3088.                 two->next = pfeil_marker->next;
  3089.                 free(pfeil_marker);
  3090.             }
  3091.         }    /* else & pfeil */
  3092.         break;
  3093.  
  3094.     case 'N':
  3095.         framedBox_marker = (struct fig3 *) obj[currIndex];
  3096.         /* redraw object */
  3097.         x = framedBox_marker->x;
  3098.         y = framedBox_marker->y;
  3099.         h = framedBox_marker->h;
  3100.         v = framedBox_marker->v;
  3101.         if (zoomed == True)
  3102.         {
  3103.             real2zoomed(&x, &y);
  3104.             real2zoomed(&h, &v);
  3105.         }
  3106.         XDrawRectangle(disp, win, gc, (int) x, (int) y,
  3107.                 (unsigned int) (h - x), (unsigned int) (v - y));
  3108.  
  3109.         if (framedBox_start == obj[currIndex])
  3110.         {    /* first entry */
  3111.             framedBox_marker = (struct fig3 *) obj[currIndex];
  3112.  
  3113.             if (framedBox_curr == framedBox_start)
  3114.             {    /* exactly 1 entry */
  3115.  
  3116.                 framedBox_start = NULL;
  3117.                 framedBox_curr = NULL;
  3118.  
  3119.             } else
  3120.                 framedBox_start = framedBox_start->next;
  3121.  
  3122.             free(framedBox_marker);
  3123.         } else
  3124.         {
  3125.             framedBox_marker = framedBox_start;
  3126.             do
  3127.             {
  3128.                 three = (struct fig3 *) framedBox_marker;
  3129.                 /* remember the last object */
  3130.                 framedBox_marker = framedBox_marker->next;
  3131.  
  3132.             } while (framedBox_marker != obj[currIndex]);
  3133.             /*
  3134.              * <framedBox_marker> points to the desired objects
  3135.              * and
  3136.              */
  3137.             /* <three> to the object before */
  3138.  
  3139.             /* last entry ? */
  3140.             if (framedBox_marker == framedBox_curr)
  3141.             {
  3142.                 framedBox_marker = NULL;
  3143.                 free(framedBox_curr);
  3144.                 framedBox_curr = three;
  3145.             } else
  3146.                 /* no! the object was somewhere in the middle */
  3147.             {
  3148.                 three->next = framedBox_marker->next;
  3149.                 free(framedBox_marker);
  3150.             }
  3151.         }    /* else & framedBox */
  3152.         break;
  3153.  
  3154.     case 'D':
  3155.         dashedBox_marker = (struct fig4 *) obj[currIndex];
  3156.         /* redraw object */
  3157.         x = dashedBox_marker->x;
  3158.         y = dashedBox_marker->y;
  3159.         h = dashedBox_marker->h;
  3160.         v = dashedBox_marker->v;
  3161.         if (zoomed == True)
  3162.         {
  3163.             real2zoomed(&x, &y);
  3164.             real2zoomed(&h, &v);
  3165.         }
  3166.         XSetLineAttributes(disp, gc, 0, LineOnOffDash, CapButt, JoinMiter);
  3167.         XDrawRectangle(disp, win, gc, (int) x, (int) y,
  3168.                 (unsigned int) (h - x), (unsigned int) (v - y));
  3169.         XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  3170.  
  3171.         if (dashedBox_start == obj[currIndex])
  3172.         {    /* first entry */
  3173.             dashedBox_marker = (struct fig4 *) obj[currIndex];
  3174.  
  3175.             if (dashedBox_curr == dashedBox_start)
  3176.             {    /* exactly 1 entry */
  3177.  
  3178.                 dashedBox_start = NULL;
  3179.                 dashedBox_curr = NULL;
  3180.  
  3181.             } else
  3182.                 dashedBox_start = dashedBox_start->next;
  3183.  
  3184.             free(dashedBox_marker);
  3185.         } else
  3186.         {
  3187.             dashedBox_marker = dashedBox_start;
  3188.             do
  3189.             {
  3190.                 four = (struct fig4 *) dashedBox_marker;
  3191.                 /* remember the last object */
  3192.                 dashedBox_marker = dashedBox_marker->next;
  3193.  
  3194.             } while (dashedBox_marker != obj[currIndex]);
  3195.             /*
  3196.              * <dashedBox_marker> points to the desired objects
  3197.              * and
  3198.              */
  3199.             /* <four> to the object before */
  3200.  
  3201.             /* last entry ? */
  3202.             if (dashedBox_marker == dashedBox_curr)
  3203.             {
  3204.                 dashedBox_marker = NULL;
  3205.                 free(dashedBox_curr);
  3206.                 dashedBox_curr = four;
  3207.             } else
  3208.                 /* no! the object was somewhere in the middle */
  3209.             {
  3210.                 four->next = dashedBox_marker->next;
  3211.                 free(dashedBox_marker);
  3212.             }
  3213.         }    /* else & dashedBox */
  3214.         break;
  3215.  
  3216.     case 'F':
  3217.         filledBox_marker = (struct fig2 *) obj[currIndex];
  3218.         /* redraw object */
  3219.         x = filledBox_marker->x;
  3220.         y = filledBox_marker->y;
  3221.         h = filledBox_marker->h;
  3222.         v = filledBox_marker->v;
  3223.         if (zoomed == True)
  3224.         {
  3225.             real2zoomed(&x, &y);
  3226.             real2zoomed(&h, &v);
  3227.         }
  3228.         XFillRectangle(disp, win, gc, (int) x, (int) y,
  3229.                 (unsigned int) (h - x), (unsigned int) (v - y));
  3230.  
  3231.         if (filledBox_start == obj[currIndex])
  3232.         {    /* first entry */
  3233.             filledBox_marker = (struct fig2 *) obj[currIndex];
  3234.  
  3235.             if (filledBox_curr == filledBox_start)
  3236.             {    /* exactly 1 entry */
  3237.  
  3238.                 filledBox_start = NULL;
  3239.                 filledBox_curr = NULL;
  3240.  
  3241.             } else
  3242.                 filledBox_start = filledBox_start->next;
  3243.  
  3244.             free(filledBox_marker);
  3245.         } else
  3246.         {
  3247.             filledBox_marker = filledBox_start;
  3248.             do
  3249.             {
  3250.                 two = (struct fig2 *) filledBox_marker;
  3251.                 /* remember the last object */
  3252.                 filledBox_marker = filledBox_marker->next;
  3253.  
  3254.             } while (filledBox_marker != obj[currIndex]);
  3255.             /*
  3256.              * <filledBox_marker> points to the desired object
  3257.              * and
  3258.              */
  3259.             /* <two> to the object before */
  3260.  
  3261.             /* last entry ? */
  3262.             if (filledBox_marker == filledBox_curr)
  3263.             {
  3264.                 filledBox_marker = NULL;
  3265.                 free(filledBox_curr);
  3266.                 filledBox_curr = two;
  3267.             } else
  3268.                 /* no! the object was somewhere in the middle */
  3269.             {
  3270.                 two->next = filledBox_marker->next;
  3271.                 free(filledBox_marker);
  3272.             }
  3273.         }    /* else & filledBox */
  3274.         break;
  3275.  
  3276.     case 'C':
  3277.         kreis_marker = (struct fig2 *) obj[currIndex];
  3278.         /* redraw object */
  3279.         x = kreis_marker->x;
  3280.         y = kreis_marker->y;
  3281.         rad = kreis_marker->radius;
  3282.  
  3283.         if (zoomed == True)
  3284.         {
  3285.             real2zoomed(&x, &y);
  3286.             rad *= 10;
  3287.         }
  3288.         XDrawArc(disp, win, gc, (int) (x - rad), (int) (y - rad),
  3289.              (unsigned int) (rad + rad),
  3290.              (unsigned int) (rad + rad), 0, 360 * 64);
  3291.  
  3292.         if (kreis_start == obj[currIndex])
  3293.         {    /* first entry */
  3294.             kreis_marker = (struct fig2 *) obj[currIndex];
  3295.  
  3296.             if (kreis_curr == kreis_start)
  3297.             {    /* exactly 1 entry */
  3298.  
  3299.                 kreis_start = NULL;
  3300.                 kreis_curr = NULL;
  3301.  
  3302.             } else
  3303.                 kreis_start = kreis_start->next;
  3304.  
  3305.             free(kreis_marker);
  3306.         } else
  3307.         {
  3308.             kreis_marker = kreis_start;
  3309.             do
  3310.             {
  3311.                 two = (struct fig2 *) kreis_marker;
  3312.                 /* remember the last object */
  3313.                 kreis_marker = kreis_marker->next;
  3314.  
  3315.             } while (kreis_marker != obj[currIndex]);
  3316.             /* <kreis_marker> points to the desired object and */
  3317.             /* <two> to the object before */
  3318.  
  3319.             /* last entry ? */
  3320.             if (kreis_marker == kreis_curr)
  3321.             {
  3322.                 kreis_marker = NULL;
  3323.                 free(kreis_curr);
  3324.                 kreis_curr = two;
  3325.             } else
  3326.                 /* no! the object was somewhere in the middle */
  3327.             {
  3328.                 two->next = kreis_marker->next;
  3329.                 free(kreis_marker);
  3330.             }
  3331.         }    /* else & kreis */
  3332.         break;
  3333.  
  3334.     case 'B':
  3335.         disc_marker = (struct fig2 *) obj[currIndex];
  3336.         /* redraw object */
  3337.         x = disc_marker->x;
  3338.         y = disc_marker->y;
  3339.         rad = disc_marker->radius;
  3340.  
  3341.         if (zoomed == True)
  3342.         {
  3343.             real2zoomed(&x, &y);
  3344.             rad *= 10;
  3345.         }
  3346.         XFillArc(disp, win, gc, (int) (x - rad), (int) (y - rad),
  3347.              (unsigned int) (rad + rad),
  3348.              (unsigned int) (rad + rad), 0, 360 * 64);
  3349.  
  3350.         if (disc_start == obj[currIndex])
  3351.         {    /* first entry */
  3352.             disc_marker = (struct fig2 *) obj[currIndex];
  3353.  
  3354.             if (disc_curr == disc_start)
  3355.             {    /* exactly 1 entry */
  3356.  
  3357.                 disc_start = NULL;
  3358.                 disc_curr = NULL;
  3359.  
  3360.             } else
  3361.                 disc_start = disc_start->next;
  3362.  
  3363.             free(disc_marker);
  3364.         } else
  3365.         {
  3366.             disc_marker = disc_start;
  3367.             do
  3368.             {
  3369.                 two = (struct fig2 *) disc_marker;
  3370.                 /* remember the last object */
  3371.                 disc_marker = disc_marker->next;
  3372.  
  3373.             } while (disc_marker != obj[currIndex]);
  3374.             /* <disc_marker> points to the desired object and */
  3375.             /* <two> to the object before */
  3376.  
  3377.             /* last entry ? */
  3378.             if (disc_marker == disc_curr)
  3379.             {
  3380.                 disc_marker = NULL;
  3381.                 free(disc_curr);
  3382.                 disc_curr = two;
  3383.             } else
  3384.                 /* no! the object was somewhere in the middle */
  3385.             {
  3386.                 two->next = disc_marker->next;
  3387.                 free(disc_marker);
  3388.             }
  3389.         }    /* else & disc */
  3390.         break;
  3391.  
  3392.     case 'O':
  3393.         oval_marker = (struct fig1 *) obj[currIndex];
  3394.         /* redraw object */
  3395.         x = oval_marker->x;
  3396.         y = oval_marker->y;
  3397.         h = oval_marker->h;
  3398.         v = oval_marker->v;
  3399.         if (zoomed == True)
  3400.         {
  3401.             real2zoomed(&x, &y);
  3402.             real2zoomed(&h, &v);
  3403.         }
  3404.         DrawOval((int) x, (int) y, (int) h, (int) v);
  3405.  
  3406.         if (oval_start == obj[currIndex])
  3407.         {    /* first entry */
  3408.             oval_marker = (struct fig1 *) obj[currIndex];
  3409.  
  3410.             if (oval_curr == oval_start)
  3411.             {    /* exactly 1 entry */
  3412.  
  3413.                 oval_start = NULL;
  3414.                 oval_curr = NULL;
  3415.  
  3416.             } else
  3417.                 oval_start = oval_start->next;
  3418.  
  3419.             free(oval_marker);
  3420.         } else
  3421.         {
  3422.             oval_marker = oval_start;
  3423.             do
  3424.             {
  3425.                 one = (struct fig1 *) oval_marker;
  3426.                 /* remember the last object */
  3427.                 oval_marker = oval_marker->next;
  3428.  
  3429.             } while (oval_marker != obj[currIndex]);
  3430.             /* <oval_marker> points to the desired object and */
  3431.             /* <one> to the object before */
  3432.  
  3433.             /* last entry ? */
  3434.             if (oval_marker == oval_curr)
  3435.             {
  3436.                 oval_marker = NULL;
  3437.                 free(oval_curr);
  3438.                 oval_curr = one;
  3439.             } else
  3440.                 /* no! the object was somewhere in the middle */
  3441.             {
  3442.                 one->next = oval_marker->next;
  3443.                 free(oval_marker);
  3444.             }
  3445.         }    /* else & oval */
  3446.         break;
  3447.  
  3448.  
  3449.  
  3450.     }    /* switch */
  3451.  
  3452. }
  3453.  
  3454.  
  3455. void
  3456. init_no_objects_sign()
  3457. {
  3458.     XtTranslations  trans_table =
  3459.     XtParseTranslationTable("<LeaveNotify>    :    XtMenuPopdown() \n");
  3460.     n = 0;
  3461.     XtSetArg(args[n], XtNheight, (XtArgVal) 250);
  3462.     n++;
  3463.     XtSetArg(args[n], XtNwidth, (XtArgVal) 250);
  3464.     n++;
  3465.     
  3466.     sign_up = XtCreatePopupShell("Report", transientShellWidgetClass, pboard, args, n);
  3467.  
  3468.     n = 0;
  3469.     XtSetArg(args[n], XtNheight, (XtArgVal) 200);
  3470.     n++;
  3471.     XtSetArg(args[n], XtNwidth, (XtArgVal) 200);
  3472.     n++;
  3473.     XtSetArg(args[n], XtNborderWidth, (XtArgVal) 5);
  3474.     n++;
  3475.     XtSetArg(args[n], XtNjustify, XtJustifyCenter);
  3476.     n++;
  3477.     XtSetArg(args[n], XtNlabel, "No valid object found !");
  3478.     n++;
  3479.     
  3480.     sign_msg = XtCreateManagedWidget("dialogue", labelWidgetClass, sign_up, args, n);
  3481.  
  3482.     XtOverrideTranslations(sign_up, trans_table);
  3483.  
  3484. }
  3485.  
  3486.  
  3487.  
  3488. void
  3489. manage_copy(void)
  3490. {
  3491.  
  3492.  
  3493.     int             index;
  3494.     unsigned int    mask;
  3495.  
  3496.  
  3497.  
  3498.  
  3499.     PointerPosition(&x_pick, &y_pick, &mask);
  3500.  
  3501.     XtUninstallTranslations(pboard);
  3502.  
  3503.     set_pick_stack(x_pick, y_pick);    /* pick_stack is filled with matching
  3504.                      * objects */
  3505.  
  3506.     index = nextObject();
  3507.  
  3508.     if (index == -1)
  3509.     {    /* no objects found */
  3510.         left();
  3511.         leave_pick("No valid object found !");
  3512.         return;
  3513.     } else
  3514.         copy_manager();
  3515. }
  3516.  
  3517.  
  3518.  
  3519. void
  3520. copy_manager()
  3521. {
  3522.     int             btn1 = 256, btn2 = 512, btn3 = 1024;
  3523.     int             index;
  3524.     int             x, y, h, v;
  3525.     unsigned int    mask, mask2;
  3526.     Display        *disp = XtDisplay(pboard);
  3527.     Window          win = XtWindow(pboard);
  3528.     headline(toplevel, "Actions: hold Button 2 to MOVE  -----  press Button 3 for MORE");
  3529.  
  3530.     while (True)
  3531.     {
  3532.  
  3533.         prepare_top_stack_object();
  3534.  
  3535.         do
  3536.         {    /* watch for any buttonPress */
  3537.             PointerPosition(&x, &y, &mask);
  3538.             if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  3539.             {
  3540.                 left();
  3541.                 prepare_top_stack_object();
  3542.                 return;
  3543.             }
  3544.             draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  3545.  
  3546.  
  3547.         } while ((!(mask & btn3)) && (!(mask & btn2)));
  3548.  
  3549.  
  3550.         /* wait for btn3 release */
  3551.         do
  3552.             PointerPosition(&x, &y, &mask2);
  3553.         while (mask2 & btn3);
  3554.  
  3555.  
  3556.  
  3557.         prepare_top_stack_object();    /* redraw */
  3558.  
  3559.  
  3560.  
  3561.         if (mask & btn2)
  3562.             copy_it(x, y);
  3563.         else
  3564.         {    /* more */
  3565.             index = nextObject();
  3566.  
  3567.             if (index == -1)
  3568.             {    /* no objects found */
  3569.                 left();
  3570.                 leave_pick("No valid object found !");
  3571.                 return;
  3572.             }
  3573.         }
  3574.  
  3575.     }    /* while */
  3576. }
  3577.  
  3578.  
  3579.  
  3580.  
  3581. void
  3582. copy_it(int x, int y)
  3583. {
  3584.     /* min. 1 object exists ! */
  3585.     struct fig1    *one, *one_mark;
  3586.     struct fig2    *two, *two_mark;
  3587.     struct fig3    *three, *three_mark;
  3588.     struct fig4    *four, *four_mark;
  3589.     struct fig6    *six, *six_mark;
  3590.     Display        *disp = XtDisplay(pboard);
  3591.     Window          win = XtWindow(pboard);
  3592.     float           ax, ay, bx, by;
  3593.     int             res, rad;
  3594.  
  3595.  
  3596.     switch (kind[currIndex])
  3597.     {
  3598.     case 'I':
  3599.         six = (struct fig6 *) malloc(sizeof(bezier));
  3600.         /* copy struct */
  3601.         bezier_marker = (struct fig6 *) obj[currIndex];
  3602.         six->ax = bezier_marker->ax + 5.0;
  3603.         six->ay = bezier_marker->ay + 5.0;
  3604.         six->ex = bezier_marker->ex + 5.0;
  3605.         six->ey = bezier_marker->ey + 5.0;
  3606.         six->sx = bezier_marker->sx + 5.0;
  3607.         six->sy = bezier_marker->sy + 5.0;
  3608.         six->next = NULL;
  3609.         bezier_marker = bezier_curr;
  3610.         bezier_curr->next = six;
  3611.         obj[currIndex] = six;
  3612.         bezier_curr = bezier_curr->next;
  3613.         /* make a copy */
  3614.         ax = six->sx;
  3615.         ay = six->sy;
  3616.         if (zoomed == True) real2zoomed(&ax, &ay);
  3617.             
  3618.         DrawBezier(six->ax, six->ay,
  3619.                six->ex, six->ey,
  3620.                ax,ay);
  3621.  
  3622.         six_mark = bezier_marker;
  3623.         break;
  3624.  
  3625.     case 'L':
  3626.         two = (struct fig2 *) malloc(sizeof(strich));
  3627.         /* copy struct */
  3628.         strich_marker = (struct fig2 *) obj[currIndex];
  3629.         two->x = strich_marker->x + 5.0;
  3630.         two->y = strich_marker->y + 5.0;
  3631.         two->h = strich_marker->h + 5.0;
  3632.         two->v = strich_marker->v + 5.0;
  3633.         two->next = NULL;
  3634.         strich_marker = strich_curr;
  3635.         strich_curr->next = two;
  3636.         obj[currIndex] = two;
  3637.         strich_curr = strich_curr->next;
  3638.         /* make a copy */
  3639.         ax = two->x;
  3640.         ay = two->y;
  3641.         bx = two->h;
  3642.         by = two->v;
  3643.         if (zoomed == True)
  3644.         {
  3645.             real2zoomed(&ax, &ay);
  3646.             real2zoomed(&bx, &by);
  3647.         }
  3648.         XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  3649.         two_mark = strich_marker;
  3650.         break;
  3651.  
  3652.     case 'V':
  3653.         two = (struct fig2 *) malloc(sizeof(pfeil));
  3654.         /* copy struct */
  3655.         pfeil_marker = (struct fig2 *) obj[currIndex];
  3656.         two->x = pfeil_marker->x + 5.0;
  3657.         two->y = pfeil_marker->y + 5.0;
  3658.         two->h = pfeil_marker->h + 5.0;
  3659.         two->v = pfeil_marker->v + 5.0;
  3660.         two->next = NULL;
  3661.         pfeil_marker = pfeil_curr;
  3662.         pfeil_curr->next = two;
  3663.         obj[currIndex] = two;
  3664.         pfeil_curr = pfeil_curr->next;
  3665.         /* make a copy */
  3666.         ax = two->x;
  3667.         ay = two->y;
  3668.         bx = two->h;
  3669.         by = two->v;
  3670.         if (zoomed == True)
  3671.         {
  3672.             real2zoomed(&ax, &ay);
  3673.             real2zoomed(&bx, &by);
  3674.         }
  3675.         XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  3676.         draw_vector_marker(ax, ay, bx, by);
  3677.         two_mark = pfeil_marker;
  3678.  
  3679.         break;
  3680.  
  3681.     case 'F':
  3682.         two = (struct fig2 *) malloc(sizeof(filledBox));
  3683.         /* copy struct */
  3684.         filledBox_marker = (struct fig2 *) obj[currIndex];
  3685.         two->x = filledBox_marker->x + 5.0;
  3686.         two->y = filledBox_marker->y + 5.0;
  3687.         two->h = filledBox_marker->h + 5.0;
  3688.         two->v = filledBox_marker->v + 5.0;
  3689.         two->next = NULL;
  3690.         filledBox_marker = filledBox_curr;
  3691.         filledBox_curr->next = two;
  3692.         obj[currIndex] = two;
  3693.         filledBox_curr = filledBox_curr->next;
  3694.         /* make a copy */
  3695.         ax = two->x;
  3696.         ay = two->y;
  3697.         bx = two->h;
  3698.         by = two->v;
  3699.         if (zoomed == True)
  3700.         {
  3701.             real2zoomed(&ax, &ay);
  3702.             real2zoomed(&bx, &by);
  3703.         }
  3704.         XFillRectangle(disp, win, gc, (int) ax, (int) ay,
  3705.             (unsigned int) (bx - ax), (unsigned int) (by - ay));
  3706.         two_mark = filledBox_marker;
  3707.         break;
  3708.  
  3709.     case 'C':
  3710.         two = (struct fig2 *) malloc(sizeof(kreis));
  3711.         /* copy struct */
  3712.         kreis_marker = (struct fig2 *) obj[currIndex];
  3713.         two->x = kreis_marker->x + 5.0;
  3714.         two->y = kreis_marker->y + 5.0;
  3715.         two->radius = kreis_marker->radius;
  3716.         two->next = NULL;
  3717.         rad = two->radius;
  3718.         kreis_marker = kreis_curr;
  3719.         kreis_curr->next = two;
  3720.         obj[currIndex] = two;
  3721.         kreis_curr = kreis_curr->next;
  3722.         /* make a copy */
  3723.         ax = two->x;
  3724.         ay = two->y;
  3725.         if (zoomed == True)
  3726.         {
  3727.             real2zoomed(&ax, &ay);
  3728.             rad *= 10;
  3729.         }
  3730.         XDrawArc(disp, win, gc, (int) (ax - rad), (int) (ay - rad),
  3731.              (unsigned int) (rad + rad),
  3732.              (unsigned int) (rad + rad), 0, 360 * 64);
  3733.         two_mark = kreis_marker;
  3734.         break;
  3735.  
  3736.  
  3737.     case 'B':
  3738.         two = (struct fig2 *) malloc(sizeof(disc));
  3739.         /* copy struct */
  3740.         disc_marker = (struct fig2 *) obj[currIndex];
  3741.         two->x = disc_marker->x + 5.0;
  3742.         two->y = disc_marker->y + 5.0;
  3743.         two->radius = disc_marker->radius;
  3744.         two->next = NULL;
  3745.         rad = two->radius;
  3746.         disc_marker = disc_curr;
  3747.         disc_curr->next = two;
  3748.         obj[currIndex] = two;
  3749.         disc_curr = disc_curr->next;
  3750.         /* make a copy */
  3751.         ax = two->x;
  3752.         ay = two->y;
  3753.         if (zoomed == True)
  3754.         {
  3755.             real2zoomed(&ax, &ay);
  3756.             rad *= 10;
  3757.         }
  3758.         XFillArc(disp, win, gc, (int) (ax - rad), (int) (ay - rad),
  3759.              (unsigned int) (rad + rad),
  3760.              (unsigned int) (rad + rad), 0, 360 * 64);
  3761.         two_mark = disc_marker;
  3762.         break;
  3763.  
  3764.     case 'N':
  3765.         three = (struct fig3 *) malloc(sizeof(framedBox));
  3766.         /* copy struct */
  3767.         framedBox_marker = (struct fig3 *) obj[currIndex];
  3768.         three->x = framedBox_marker->x + 5.0;
  3769.         three->y = framedBox_marker->y + 5.0;
  3770.         three->h = framedBox_marker->h + 5.0;
  3771.         three->v = framedBox_marker->v + 5.0;
  3772.         three->next = NULL;
  3773.         framedBox_marker = framedBox_curr;
  3774.         framedBox_curr->next = three;
  3775.         obj[currIndex] = three;
  3776.         framedBox_curr = framedBox_curr->next;
  3777.         /* make a copy */
  3778.         ax = three->x;
  3779.         ay = three->y;
  3780.         bx = three->h;
  3781.         by = three->v;
  3782.         three->text = (char *) malloc(strlen(framedBox_marker->text) + 1);
  3783.         strcpy(three->text, framedBox_marker->text);
  3784.         strcpy(three->textpos, framedBox_marker->textpos);
  3785.         if (zoomed == True)
  3786.         {
  3787.             real2zoomed(&ax, &ay);
  3788.             real2zoomed(&bx, &by);
  3789.         }
  3790.         XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  3791.             (unsigned int) (bx - ax), (unsigned int) (by - ay));
  3792.         print_box_text(three->textpos, ax, ay, bx, by, three->text);
  3793.         three_mark = framedBox_marker;
  3794.         break;
  3795.  
  3796.     case 'D':
  3797.         four = (struct fig4 *) malloc(sizeof(dashedBox));
  3798.         /* copy struct */
  3799.         dashedBox_marker = (struct fig4 *) obj[currIndex];
  3800.         four->x = dashedBox_marker->x + 5.0;
  3801.         four->y = dashedBox_marker->y + 5.0;
  3802.         four->h = dashedBox_marker->h + 5.0;
  3803.         four->v = dashedBox_marker->v + 5.0;
  3804.         four->next = NULL;
  3805.         dashedBox_marker = dashedBox_curr;
  3806.         dashedBox_curr->next = four;
  3807.         obj[currIndex] = four;
  3808.         dashedBox_curr = dashedBox_curr->next;
  3809.         /* make a copy */
  3810.         ax = four->x;
  3811.         ay = four->y;
  3812.         bx = four->h;
  3813.         by = four->v;
  3814.         four->text = (char *) malloc(strlen(dashedBox_marker->text) + 1);
  3815.         strcpy(four->text, dashedBox_marker->text);
  3816.         strcpy(four->textpos, dashedBox_marker->textpos);
  3817.         if (zoomed == True)
  3818.         {
  3819.             real2zoomed(&ax, &ay);
  3820.             real2zoomed(&bx, &by);
  3821.         }
  3822.         XSetLineAttributes(disp, gc, 0, LineOnOffDash, CapButt, JoinMiter);
  3823.         XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  3824.             (unsigned int) (bx - ax), (unsigned int) (by - ay));
  3825.         XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  3826.         print_box_text(four->textpos, ax, ay, bx, by, four->text);
  3827.         four_mark = dashedBox_marker;
  3828.         break;
  3829.  
  3830.     case 'O':
  3831.         one = (struct fig1 *) malloc(sizeof(oval));
  3832.         /* copy struct */
  3833.         oval_marker = (struct fig1 *) obj[currIndex];
  3834.         one->x = oval_marker->x + 5.0;
  3835.         one->y = oval_marker->y + 5.0;
  3836.         one->h = oval_marker->h + 5.0;
  3837.         one->v = oval_marker->v + 5.0;
  3838.         one->next = NULL;
  3839.         oval_marker = oval_curr;
  3840.         oval_curr->next = one;
  3841.         obj[currIndex] = one;
  3842.         oval_curr = oval_curr->next;
  3843.         /* make a copy */
  3844.         ax = one->x;
  3845.         ay = one->y;
  3846.         bx = one->h;
  3847.         by = one->v;
  3848.         if (zoomed == True)
  3849.         {
  3850.             real2zoomed(&ax, &ay);
  3851.             real2zoomed(&bx, &by);
  3852.         }
  3853.         DrawOval(ax, ay, bx, by);
  3854.         one_mark = oval_marker;
  3855.         break;
  3856.  
  3857.     default:
  3858.         break;
  3859.  
  3860.     }    /* switch */
  3861.  
  3862.  
  3863.  
  3864.     res = pick_move(x, y);
  3865.  
  3866.  
  3867.  
  3868.  
  3869.     if (res == -1)
  3870.     {    /* cancel */
  3871.         switch (kind[currIndex])
  3872.         {
  3873.         case 'I':
  3874.             bezier_curr = six_mark;
  3875.             bezier_curr->next = NULL;
  3876.             free(six);
  3877.             break;
  3878.  
  3879.         case 'L':
  3880.             strich_curr = two_mark;
  3881.             strich_curr->next = NULL;
  3882.             free(two);
  3883.             break;
  3884.  
  3885.         case 'V':
  3886.             pfeil_curr = two_mark;
  3887.             pfeil_curr->next = NULL;
  3888.             free(two);
  3889.             break;
  3890.  
  3891.         case 'B':
  3892.             disc_curr = two_mark;
  3893.             disc_curr->next = NULL;
  3894.             free(two);
  3895.             break;
  3896.  
  3897.         case 'C':
  3898.             kreis_curr = two_mark;
  3899.             kreis_curr->next = NULL;
  3900.             free(two);
  3901.             break;
  3902.  
  3903.         case 'F':
  3904.             filledBox_curr = two_mark;
  3905.             filledBox_curr->next = NULL;
  3906.             free(two);
  3907.             break;
  3908.  
  3909.         case 'O':
  3910.             oval_curr = one_mark;
  3911.             oval_curr->next = NULL;
  3912.             free(one);
  3913.             break;
  3914.  
  3915.         case 'N':
  3916.             framedBox_curr = three_mark;
  3917.             framedBox_curr->next = NULL;
  3918.             free(three);
  3919.             break;
  3920.  
  3921.         case 'D':
  3922.             dashedBox_curr = four_mark;
  3923.             dashedBox_curr->next = NULL;
  3924.             free(four);
  3925.             break;
  3926.  
  3927.         default:
  3928.             break;
  3929.  
  3930.         }    /* switch */
  3931.         refresh(pboard, '?', (caddr_t)DUMMY);
  3932.     }    /* cancel */
  3933. }/* copy_it */
  3934.